【问题标题】:how to do this for all emulators如何为所有模拟器执行此操作
【发布时间】:2011-12-08 12:36:30
【问题描述】:
<RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="365dp"
        android:layout_margin="10dp"
        android:background="@drawable/round_border" >
    <RelativeLayout 
        android:id="@+id/relativeLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageButton
            android:id="@+id/contactimg"
            style="@style/CodeFont"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/round_border_imageview"
            android:maxHeight="75dp"
            android:maxWidth="75dp"
            android:padding="2dp"
            android:src="@drawable/icon"
            android:textSize="15dp" >
        </ImageButton>

</RelativeLayout>
<RelativeLayout 
        android:id="@+id/relativeLayout4"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/relativeLayout2">

            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="20dp"
                android:weightSum="1" 
                android:background="@drawable/round_border">
            <TextView
            android:id="@+id/TextView03"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="Textttt"
            android:padding="10dp" />

            </LinearLayout>


        </RelativeLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/relativeLayout5"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="1dp"
        android:layout_below="@+id/relativeLayout1"
        >

        <Button
            android:id="@+id/replaymassegebutton"
            android:layout_width="80dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="10dp"
            android:background="@drawable/button_indicator"
            android:text="Reply"
            android:textColor="@color/gray2" >
        </Button>
</RelativeLayout>

在 HVGA 模拟器中,它的措辞很好。但在另一个模拟器中却不是。如您所见,我输入了 height=365dp,(我必须更改高度,但我不知道如何,365dp 仅在 HVGA 模式下工作)我应该在这里做什么,以便它适用于所有模拟器。我尝试了 wrap_content 和 fill_parrent 但是当我设置这个参数时,按钮消失了(它们在另一个布局中)。我也试过这种方式 android:layout_weight="1" android:layout_height="0dp"。但这里没有结果。你能不能给我另一个解决方案

【问题讨论】:

  • 需要更多... 1. 什么是父布局?线性的,相对的还是什么? 2.按钮总是在底部吗?并且您希望此 UI 覆盖屏幕上的剩余区域?编辑您的问题... 至少详细说明并添加您认为适合分享的任何内容.....这将使我们轻松发布答案
  • 父布局是线性的。 Buttuns 必须在底部。

标签: android xml android-layout


【解决方案1】:

最好将父布局设为相对。

  1. 您可以将按钮始终放在底部-通过在按钮的属性中设置android:layout_alignParentBottom="true" [或按钮管理器,以防有多个按钮]...

  2. 对于剩余的屏幕,您可能必须在那里使用LinearLayout,将其用作即时孩子并在那里安排您的原始视图.. 将其设置为android:layout_alignParentTop="true" 并将您的按钮视图放在它下方.. .通过将此android:layout_below=添加到按钮视图..这将使您的线性布局获得按钮未占用的所有剩余空间....在较小的屏幕情况下将滚动视图添加为线性布局的直接子级...

而且你最不用担心多屏......

享受

【讨论】:

  • 永远是兄弟!很高兴为您提供帮助... :)
猜你喜欢
  • 2020-05-30
  • 2011-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-10
  • 2021-06-19
  • 2013-01-19
  • 2021-10-27
相关资源
最近更新 更多