【发布时间】:2013-12-27 03:11:28
【问题描述】:
我的屏幕上有一个按钮、一个 textView 和一个 scrollView。我需要 button 和 textView 在顶部彼此并排,scrollView 在它们下方。如何专业地在屏幕上排列视图?!
这就是我所做的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:textDirection="inherit"
tools:context=".MainActivity" >
<Button
android:id="@+id/btnScanAndDraw"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/btnShoePosition"
android:textSize="12sp"
android:onClick="ScanAndDraw"/>
<TextView
android:id="@+id/txvMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="end">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/imgViewMap"/>
</LinearLayout>
</ScrollView>
【问题讨论】:
-
第一步:尝试一下。
-
所以我在顶部做了一个线性布局。但他们都并肩作战。我尝试了视图的 margin_top 属性,但只是想知道这是最好的方法还是有其他方法!
-
发布一些带有布局外观截图的代码会更容易。
-
好的@mikeaworski 我做到了:)
-
现在人们可以将该代码复制到自己的 xml 中并自行操作。布局的屏幕截图也不错,但这不是必需的。