【问题标题】:If there is no space horizontally on the screen go to the next vertically available space?如果屏幕上没有水平空间,转到下一个垂直可用空间?
【发布时间】:2011-10-10 11:43:33
【问题描述】:

Android 专家您好,

我有以下布局:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
<ImageButton android:id="@+id/ImageButton02"
android:layout_width="80px" 
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
</LinearLayout>

此布局的图像按钮会离开屏幕并变得不可见。我想从新行开始。

我们将不胜感激。

提前致谢。 :)

【问题讨论】:

  • 也许this question的第一个回答对你有帮助?
  • 谢谢@scessor,这正是我想要的。我真的很感谢你:D

标签: android android-layout android-linearlayout


【解决方案1】:

求和按钮的像素值大于屏幕尺寸的像素值,android中没有view会自动换行。如果您希望按钮转到下一行,则需要创建另一个布局视图并将一些按钮放在那里。

您可能还想调整布局的方向:http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:orientation

另外,作为一个方面,你真的应该使用 dp 或 sp 而不是 px。 What is the difference between "px", "dp", "dip" and "sp" on Android?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 2019-01-26
    相关资源
    最近更新 更多