Android 是否可以在同一行上创建布局和视图翻转器?
是否可以通过以下方式创建屏幕 !![屏幕][2] 当我更改页面时,每个页面上都显示相同的布局Android 是否可以在同一行上创建布局和视图翻转器?,android,android-layout,Android,Android Layout,是否可以通过以下方式创建屏幕 !![屏幕][2] 当我更改页面时,每个页面上都显示相同的布局 关于是的,布局是可能的: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ViewFlipper android:layout_width="fill_parent" android:layout_height="fill_
关于是的,布局是可能的:
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ViewFlipper android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ViewFlipper>
<!-- I assumed your layout at the top-left corner is a LinearLayout, otherwise replace it with what you have -->
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:id="@+id/firstLayout">
</LinearLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/firstLayout"
android:layout_margin="5dp"/>
</RelativeLayout>
编辑:
您的问题有点含糊不清,如果您只想在布局中的
布局
元素附近添加文本视图
,则添加文本视图
,并将其设置为toRightOf
属性(带有一些边距以留出一些间隙)。检查上面布局中的修改。如果您希望文本视图
像图片中那样垂直居中(考虑到布局
的高度),那么您可以将布局
和文本视图
包装成线性布局
(宽度和高度设置为包装内容
)在父级RelativeLayout
中对齐左上角,您的问题不是很清楚,但我怀疑您所寻找的正是Kursprog提供给您的,只是您希望将左上角布局和文本视图放入包装器线性布局中,因此您的xml看起来是这样的(减去所有属性)
您需要给包装器一个fill\u parent的宽度,并将两个内部元素的布局权重设置为1,以便它们在屏幕上均匀分布 我解决了框架布局的问题。框架布局允许重叠视图谢谢,我也试过了。但是在这种情况下:我需要将textview设置到布局的一侧(在同一行上),viewflipperI的幻灯片转换解决了FrameLayout的问题。允许重叠视图的框架布局
<RelativeLayout> <!--Parent -->
<ViewFlipper/>
<LinearLayout android:orientation="horizontal"><!-- wrapper to your two top layouts
<LinearLayout/> <!-- whatever layout it is that you're describing in your diagram -->
<TextView/> <!-- the text view in your diagram -->
</LinearLayout>
</RelativeLayout>