Android LinearLayout:布局中的布局
我被Android的布局设计搞糊涂了。我希望实现下图中的布局: 但下面的代码生成了类似于此图像的内容: 我的代码Android LinearLayout:布局中的布局,android,android-layout,android-linearlayout,Android,Android Layout,Android Linearlayout,我被Android的布局设计搞糊涂了。我希望实现下图中的布局: 但下面的代码生成了类似于此图像的内容: 我的代码 <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="50sp" android:layout_below="@+id/view" andro
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_below="@+id/view"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/bg_shadow"
android:animateLayoutChanges="true"
android:layout_marginTop="5dp"
android:id="@+id/detailsLay">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/repeat"
android:id="@+id/repeatCheckBox"
android:longClickable="false"
android:textColor="@android:color/background_light"
android:paddingTop="15sp"
android:paddingRight="15sp"
android:paddingLeft="1sp"
android:paddingBottom="15sp" />
<TextView
android:layout_width="30dp"
android:layout_height="20sp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/sat"
android:id="@+id/satTextView"
android:layout_gravity="center_vertical|right"
android:textColor="@android:color/holo_orange_light"
android:layout_marginLeft="2sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/arrowDown"
android:src="@android:drawable/arrow_down_float"
android:layout_gravity="center_vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/everyday"/>
</LinearLayout>
</LinearLayout>
这只是一个示例Xml,可以从中学习
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CheckBox" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
使用线性布局的权重和用户方向等属性。使用
relativeLayout
替代使用relativeLayout
否则对LinearLayour2使用不同的布局