【发布时间】:2017-09-21 22:24:27
【问题描述】:
我知道这个问题被问了很多,因为我尝试了很多张贴在这里的例子,但我就是不能让它工作,这就是我所拥有的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="#3F51B5"
android:padding="5dp"
android:paddingBottom="500dp">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/linearLayout2"
android:gravity="bottom"
android:layout_weight="1">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnTarjeta"
android:background="@color/my_purple"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp" />
<TextView
android:text="Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/my_white"
android:id="@+id/textView1"
android:fontFamily="sans-serif-medium"
android:layout_marginBottom="10dp" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/radioGp"
android:minWidth="25px"
android:minHeight="25px"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3"
android:layout_gravity="bottom">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button2" />
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1" />
</LinearLayout>
</LinearLayout>
其中一个可能是“问题”的事情是我正在动态填充单选组内的单选按钮,所以有时可能是 4 个单选按钮,而在其他时候可能是 1,我不知道如果这会影响我正在尝试做的任何事情。
我想要做的是将第一个线性层保持在顶部,将第二个线性层保持在按钮上。我做错了什么?
【问题讨论】: