//效果图:
//代码
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button1=(Button)this.findViewById(R.id.button); Button button2=(Button)this.findViewById(R.id.button2); //layout:设计、params:参数 button1.setLayoutParams(new LinearLayout .LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT,1)); button2.setLayoutParams(new LinearLayout .LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,2)); }
//demo2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.layoutdemo.MainActivity$PlaceholderFragment" > <TextView android:layout_width="fill_parent" android:layout_height="45dip" android:background="@drawable/a" android:gravity="center" android:text="设 置" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="0.0dp" android:layout_weight="1.0" > <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/ic_launcher" /> </LinearLayout> <TextView android:layout_width="fill_parent" android:layout_height="45dip" android:background="@drawable/a" android:drawableLeft="@drawable/ic_launcher" android:gravity="center_vertical" android:text="小机器人" /> </LinearLayout>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。