【问题标题】:Bottom button is cut off in my layout, we can't see the whole layout底部按钮在我的布局中被切断,我们看不到整个布局
【发布时间】:2011-09-15 18:45:54
【问题描述】:

我正在使用相对布局来生成看起来像图像一的东西。但在某些手机上(见图 2),底部按钮被切断,我们无法看到整个布局。相对布局的目的不就是根据自己是什么手机来调整自己吗?

我能做些什么来解决这个问题?如果没有简单的方法,我应该让它向下滚动以便我们可以看到按钮吗?

谢谢

这是我的 xml 布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:background="@drawable/settings" android:layout_height="fill_parent"
    android:weightSum="1">
    <RelativeLayout android:layout_width="fill_parent" android:layout_height="45dp" android:background="@drawable/mytitlebackground">
        <Button android:layout_height="wrap_content" android:id="@+id/btnDeleteAccount" android:layout_width="wrap_content" android:text="@string/deleteaccount" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"></Button>
        <Button android:layout_height="wrap_content" android:id="@+id/btnhistory" android:layout_width="wrap_content" android:text="@string/history" android:layout_alignParentTop="true" android:layout_alignParentRight="true"></Button>
    </RelativeLayout>
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="262dp" android:layout_height="80dp" android:background="#333333" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="17dp">
        <TextView android:textStyle="bold" android:textColor="#ffffff" android:textSize="13sp" android:layout_marginTop="14dp" android:layout_marginLeft="14dp" android:text="@string/Name" android:layout_alignParentLeft="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:id="@+id/textView2"></TextView>
        <TextView android:textStyle="bold" android:textSize="13sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:id="@+id/textView3" android:text="@string/BackgroundUpdates" android:layout_below="@+id/textView2" android:layout_alignLeft="@+id/textView2" android:layout_marginTop="16dp"></TextView>
        <ToggleButton android:layout_width="wrap_content" android:id="@+id/toggleButtonBGUpdates" android:layout_height="wrap_content" android:layout_below="@+id/tVName" android:layout_toRightOf="@+id/textView3" android:layout_marginLeft="28dp"></ToggleButton>
        <TextView android:textSize="13sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:id="@+id/tVName" android:text="name" android:layout_alignTop="@+id/textView2" android:layout_toRightOf="@+id/textView2" android:layout_marginLeft="19dp"></TextView>
    </RelativeLayout>
    <TextView android:text="@string/GPSInformation" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:id="@+id/textView4" android:layout_below="@+id/relativeLayout1" android:layout_centerHorizontal="true" android:layout_marginTop="16dp"></TextView>
    <RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="262dp" android:layout_height="130dp" android:background="#333333" android:layout_below="@+id/textView4" android:layout_alignLeft="@+id/relativeLayout1">
        <ImageView android:layout_marginLeft="18dp" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:id="@+id/imageView1" android:layout_height="wrap_content" android:src="@drawable/fullbattery" android:layout_marginBottom="14dp"></ImageView>
        <ImageView android:layout_alignTop="@+id/imageView1" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_marginRight="18dp" android:id="@+id/imageView2" android:layout_height="wrap_content" android:src="@drawable/halfbattery"></ImageView>
        <RadioGroup android:layout_width="wrap_content" android:layout_alignParentTop="true" android:id="@+id/rGTimer" android:orientation="horizontal" android:layout_alignParentLeft="true" android:layout_height="wrap_content">
            <RadioButton android:layout_height="wrap_content" android:id="@+id/r30mins" android:text="@string/updateevery30mins" android:textSize="13sp" android:layout_width="130dp" android:checked="true"></RadioButton>
            <RadioButton android:layout_height="wrap_content"
    android:id="@+id/r10mins" android:text="@string/updateevery10mins"
    android:textSize="13sp" android:layout_width="130dp"></RadioButton>
        </RadioGroup>
    </RelativeLayout>
    <Button android:layout_height="wrap_content" android:id="@+id/btnRenableHelpScreen" android:layout_width="wrap_content" android:text="@string/Turnonhelpscreens" android:layout_below="@+id/relativeLayout2" android:layout_alignRight="@+id/textView4" android:layout_marginTop="14dp"></Button>
    <TextView android:text="@string/AccountInformation" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:id="@+id/textView1" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="55dp"></TextView>

</RelativeLayout>

【问题讨论】:

  • 尝试将 weight=1 赋予按钮及其周围的所有东西。应该修复它。

标签: android android-layout android-relativelayout


【解决方案1】:

有两种方法。

  1. 您应该根据您在 Android 中的布局创建图像。正确设置它们,您的帮助屏幕按钮是否正确,问题就解决了,但有时会产生图像模糊问题,而且您必须减少组件之间的空间。而且这是最好的方式,我在很多应用中都使用过这种方式。

  2. 从第一个布局开始添加滚动条。

【讨论】:

    【解决方案2】:

    请检查显示选项卡下手机设置中的字体大小 如果已经调整过了,那么就得用dp代替sp来设置Text View的textsize

    这适用于我的问题,也应该适用于您的问题。

    【讨论】:

      猜你喜欢
      • 2016-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多