Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android垂直对齐文本和小部件_Android_Android Layout_Android Widget_Android Xml - Fatal编程技术网

Android垂直对齐文本和小部件

Android垂直对齐文本和小部件,android,android-layout,android-widget,android-xml,Android,Android Layout,Android Widget,Android Xml,我在水平线性布局中使用文本标签和无线电组: 如何设置,使标签(性别)显示在广播组的垂直中心?目前它似乎太高了 我的布局的这一部分的代码是: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView

我在水平线性布局中使用文本标签和无线电组:

如何设置,使标签(性别)显示在广播组的垂直中心?目前它似乎太高了

我的布局的这一部分的代码是:

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.4"
            android:text="Sex:" />

        <RadioGroup
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:orientation="horizontal">

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Male"
                android:id="@+id/input_button_male"
                android:paddingRight="10dp"/>

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Female"
                android:id="@+id/input_button_female"
                android:paddingRight="10dp"/>
        </RadioGroup>

    </LinearLayout>

我认为您可以在文本视图中使用
android:layout_marginTop=“?”
。 或者,您可以在Textview中使用android:gravity=“center\u vertical”。可能是后者

i、 e


我认为您可以在文本视图中使用
android:layout_marginTop=“?”
。 或者,您可以在Textview中使用android:gravity=“center\u vertical”。可能是后者

i、 e


你想这样做,然后把你的文本视图下面的代码

android:layout\u gravity=“center\u vertical”

你想这样做,然后把你的文本视图下面的代码

android:layout\u gravity=“center\u vertical”
看看这个

android:layout width=“0dp”不推荐!首选androd:layout width=“包装内容”


看看这个

android:layout width=“0dp”不推荐!首选androd:layout width=“包装内容”


 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.4"
        android:layout_gravity="center_vertical"
        android:text="Sex:" />

    <RadioGroup
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.6"
        android:orientation="horizontal">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Male"
            android:id="@+id/input_button_male"
            android:paddingRight="10dp"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Female"
            android:id="@+id/input_button_female"
            android:paddingRight="10dp"/>
    </RadioGroup>

</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">

<TextView
    android:layout_marginLeft="48dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|center_vertical"
    android:layout_weight="0.4"
    android:text="Sex :"
    android:textSize="20sp" />

<RadioGroup
    android:layout_marginRight="72dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="0.6"
    android:orientation="horizontal">

    <RadioButton
        android:id="@+id/input_button_male"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingRight="10dp"
        android:text="Male" />

    <RadioButton
        android:id="@+id/input_button_female"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingRight="10dp"
        android:text="Female" />
</RadioGroup>