android 我怎样才能强制按钮行保持相同的大小

发布于 2024-11-19 10:16:05 字数 6724 浏览 3 评论 0原文

看看图片也许很明显问题是什么。
按钮行坚持在纵向情绪中变大。

删除

android:layout_below="@+id/cb_delete_files_option_activity"

后,

@+id/cb_delete_files_option_activity

复选框在横向模式下不可见。

有人有什么想法吗?

在此处输入图像描述

在此输入图像描述

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/ScrollView01"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    >
    <RelativeLayout android:id="@+id/topRelativeLayout"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:background="@color/send_background_color" 

        >

        <TextView android:id="@+id/txt1_option_activity"
            android:text = ""
            android:textColor="#FFFFFF"
            android:textSize="20sp"
            android:layout_marginTop="20dip"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:gravity="center_vertical|center_horizontal"
            android:layout_alignParentTop="true"
        />
        <TextView
            android:id="@+id/txt2_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="20sp"
            android:textColor="#ffffffff"
            android:layout_centerHorizontal="true"
            android:layout_below="@+id/txt1_option_activity"
            >
        </TextView>
        <View android:id="@+id/just_a_line_option_activity"
            android:background="#ffffff"
            android:layout_width = "fill_parent"
            android:layout_height="1dip"
            android:layout_below="@+id/txt2_option_activity"
            >
        </View>

        <TextView
            android:id="@+id/txt3_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textColor="#ffffffff"
            android:layout_below="@+id/just_a_line_option_activity"
            android:layout_centerHorizontal="true"
            >
        </TextView>

        <TextView
            android:id="@+id/txt_spinner_filesize_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/txt3_option_activity"
            android:layout_toRightOf="@+id/spinner_filesize_option_activity"
            >
        </TextView>
        <Spinner android:id="@+id/spinner_filesize_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txt3_option_activity"
            >
        </Spinner>

        <TextView
            android:id="@+id/txt_spinner_notificationtype_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/spinner_filesize_option_activity"
            android:layout_toRightOf="@+id/spinner_notificationtype_option_activity"

            >
        </TextView>
        <Spinner android:id="@+id/spinner_notificationtype_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_below="@+id/spinner_filesize_option_activity"

            >
        </Spinner>
        <TextView
            android:id="@+id/txt_spinner_delay_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/spinner_notificationtype_option_activity"
            android:layout_toRightOf="@+id/etx_delay_option_activity"

            >
        </TextView>
        <EditText android:id="@+id/etx_delay_option_activity"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/spinner_notificationtype_option_activity"
            android:singleLine="true"
            android:text="0"
        />
        <CheckBox
            android:id="@+id/cb_delete_files_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:layout_below="@+id/etx_delay_option_activity"
            android:layout_alignParentLeft="true"

            >
        </CheckBox>

        <LinearLayout android:id="@+id/linerLayout_send_button_row"
            android:orientation="horizontal"
            android:background="@android:drawable/bottom_bar" 
            android:paddingLeft="4.0dip"
            android:paddingTop="5.0dip" 
            android:paddingRight="4.0dip"
            android:paddingBottom="1.0dip" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" 
            android:layout_below="@+id/cb_delete_files_option_activity"

            >
            <Button android:id="@+id/btn_send_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="Send"
                android:layout_weight="1.0"

            />
            <Button android:id="@+id/btn_more_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="More"
                android:layout_weight="1.0"

            />
        </LinearLayout>
    </RelativeLayout>
</ScrollView>

looking at the pictures maybe it's obvious what the problem is.
The button row insist on getting to big in portrait mood.

Remove the

android:layout_below="@+id/cb_delete_files_option_activity"

then the

@+id/cb_delete_files_option_activity

checkbox is not visible in landscape mood.

anyone have some ide?

enter image description here

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/ScrollView01"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    >
    <RelativeLayout android:id="@+id/topRelativeLayout"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:background="@color/send_background_color" 

        >

        <TextView android:id="@+id/txt1_option_activity"
            android:text = ""
            android:textColor="#FFFFFF"
            android:textSize="20sp"
            android:layout_marginTop="20dip"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:gravity="center_vertical|center_horizontal"
            android:layout_alignParentTop="true"
        />
        <TextView
            android:id="@+id/txt2_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="20sp"
            android:textColor="#ffffffff"
            android:layout_centerHorizontal="true"
            android:layout_below="@+id/txt1_option_activity"
            >
        </TextView>
        <View android:id="@+id/just_a_line_option_activity"
            android:background="#ffffff"
            android:layout_width = "fill_parent"
            android:layout_height="1dip"
            android:layout_below="@+id/txt2_option_activity"
            >
        </View>

        <TextView
            android:id="@+id/txt3_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textColor="#ffffffff"
            android:layout_below="@+id/just_a_line_option_activity"
            android:layout_centerHorizontal="true"
            >
        </TextView>

        <TextView
            android:id="@+id/txt_spinner_filesize_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/txt3_option_activity"
            android:layout_toRightOf="@+id/spinner_filesize_option_activity"
            >
        </TextView>
        <Spinner android:id="@+id/spinner_filesize_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txt3_option_activity"
            >
        </Spinner>

        <TextView
            android:id="@+id/txt_spinner_notificationtype_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/spinner_filesize_option_activity"
            android:layout_toRightOf="@+id/spinner_notificationtype_option_activity"

            >
        </TextView>
        <Spinner android:id="@+id/spinner_notificationtype_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_below="@+id/spinner_filesize_option_activity"

            >
        </Spinner>
        <TextView
            android:id="@+id/txt_spinner_delay_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:textColor="#ffffffff"
            android:layout_below="@+id/spinner_notificationtype_option_activity"
            android:layout_toRightOf="@+id/etx_delay_option_activity"

            >
        </TextView>
        <EditText android:id="@+id/etx_delay_option_activity"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dip"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/spinner_notificationtype_option_activity"
            android:singleLine="true"
            android:text="0"
        />
        <CheckBox
            android:id="@+id/cb_delete_files_option_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="some settings"
            android:layout_below="@+id/etx_delay_option_activity"
            android:layout_alignParentLeft="true"

            >
        </CheckBox>

        <LinearLayout android:id="@+id/linerLayout_send_button_row"
            android:orientation="horizontal"
            android:background="@android:drawable/bottom_bar" 
            android:paddingLeft="4.0dip"
            android:paddingTop="5.0dip" 
            android:paddingRight="4.0dip"
            android:paddingBottom="1.0dip" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" 
            android:layout_below="@+id/cb_delete_files_option_activity"

            >
            <Button android:id="@+id/btn_send_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="Send"
                android:layout_weight="1.0"

            />
            <Button android:id="@+id/btn_more_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="More"
                android:layout_weight="1.0"

            />
        </LinearLayout>
    </RelativeLayout>
</ScrollView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫瑾少女 2024-11-26 10:16:05

RelativeLayout 中,它应该是 android:layout_height="wrap_content",而不是 fill_parent

In the RelativeLayout, it should be android:layout_height="wrap_content", NOT fill_parent.

狼亦尘 2024-11-26 10:16:05

将包含按钮的整个 LinearLayout 包装在新的 RelativeLayout 中,将 android:layout_below="@+id/cb_delete_files_option_activity" 放入其中,而不是在 LinearLayout 中:

    <!-- the rest of your xml -->
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cb_delete_files_option_activity"
    >
        <LinearLayout android:id="@+id/linerLayout_send_button_row"
            android:orientation="horizontal"
            android:background="@android:drawable/bottom_bar" 
            android:paddingLeft="4.0dip"
            android:paddingTop="5.0dip" 
            android:paddingRight="4.0dip"
            android:paddingBottom="1.0dip" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            >
            <Button android:id="@+id/btn_send_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="Send"
                android:layout_weight="1.0"

            />
            <Button android:id="@+id/btn_more_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="More"
                android:layout_weight="1.0"

            />
        </LinearLayout>
    </RelativeLayout>
    <!-- the rest of your xml -->

Wrap your entire LinearLayout containing the buttons inside a NEW RelativeLayout, placing the android:layout_below="@+id/cb_delete_files_option_activity" inside it instead of in the LinearLayout:

    <!-- the rest of your xml -->
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cb_delete_files_option_activity"
    >
        <LinearLayout android:id="@+id/linerLayout_send_button_row"
            android:orientation="horizontal"
            android:background="@android:drawable/bottom_bar" 
            android:paddingLeft="4.0dip"
            android:paddingTop="5.0dip" 
            android:paddingRight="4.0dip"
            android:paddingBottom="1.0dip" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            >
            <Button android:id="@+id/btn_send_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="Send"
                android:layout_weight="1.0"

            />
            <Button android:id="@+id/btn_more_activity_send_nr_two"
                android:layout_width="0.0dip"
                android:layout_height="fill_parent"
                android:text="More"
                android:layout_weight="1.0"

            />
        </LinearLayout>
    </RelativeLayout>
    <!-- the rest of your xml -->
宁愿没拥抱 2024-11-26 10:16:05

对两个按钮使用 android:layout_height="wrap_content" 并从线性布局中删除 android:layout_below="@+id/cb_delete_files_option_activity"

Use android:layout_height="wrap_content" for both buttons and delete android:layout_below="@+id/cb_delete_files_option_activity" from your linear layout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文