【问题标题】:Stacking Two ImageButtons堆叠两个 ImageButton
【发布时间】:2010-07-22 19:25:36
【问题描述】:

我有两个 ImageButton,我试图将一个堆叠在另一个之上。我基本上想用两个大按钮制作一个屏幕,每个按钮占据 50% 的可用空间。代码如下。这是它产生的布局的捕获http://imgur.com/cQT0W.png 我在父级上玩过 layout_gravity 和重力。将两个孩子都设置为 layout_height=fill_parent 不起作用,将父级的重力设置为 fill_vertical 也不起作用。

        <!-- Notes tab -->
        <LinearLayout android:id="@+id/tabNotes"  
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"             
            android:padding="6dp"
            android:orientation="vertical">                                                 
            <ImageButton android:src="@drawable/ic_btn_speak_now" android:id="@+id/imgSpeakNow"                         
                android:background="#FFFF00"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />                  
            <ImageButton android:src="@drawable/ic_btn_compose" android:id="@+id/imgCompose" 
                android:background="#FF00FF"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"                                    
                />
        </LinearLayout>

【问题讨论】:

    标签: android layout imageview imagebutton android-linearlayout


    【解决方案1】:

    使用 android:layout_weight;将两个按钮设置为具有相同的值。

    使用 RelativeLayout 而不是 LinearLayout 也可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2011-03-31
      • 1970-01-01
      • 2020-01-02
      相关资源
      最近更新 更多