Android 垂直居中线性布局内的一个视图,带有两个视图
我想强迫仪表垂直居中于Lliner之上。。。 我只是好像没办法 而不是llTop使用所有可用空间,它正在这样做 多谢各位Android 垂直居中线性布局内的一个视图,带有两个视图,android,android-linearlayout,footer,centering,Android,Android Linearlayout,Footer,Centering,我想强迫仪表垂直居中于Lliner之上。。。 我只是好像没办法 而不是llTop使用所有可用空间,它正在这样做 多谢各位 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llTop" android:layout_width="match_parent" android:layout_height="match_parent" android:orientat
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llTop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#ff0000">
<eu.sextante.speedlimit.Views.GaugeView
android:id="@+id/gauge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<LinearLayout
android:id="@+id/llInner"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="bottom|right"
android:gravity="bottom|right"
android:background="#00ff00">
<eu.sextante.speedlimit.Views.LimitView
android:id="@+id/limit"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:background="#0000ff"
android:maxHeight="60dip"
android:maxWidth="60dip"/>
</LinearLayout>
应使用相对布局作为主布局,如下所示:
<RelativeLayout 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"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/llInner"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom|right"
android:background="#00ff00"
android:gravity="bottom|right"
android:orientation="horizontal" >
<eu.sextante.speedlimit.Views.LimitView
android:id="@+id/limit"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:background="#0000ff"
android:maxHeight="60dip"
android:maxWidth="60dip" />
</LinearLayout>
<your.gaugeview
android:id="@+id/gauge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="dfdg" />
</RelativeLayout>
希望它能帮助你。在你的电脑中使用android:gravity=center | right而不是android:gravity=bottom | rightLinearLayout@R9j,保持不变。。。llTop仍然只围绕内容进行包装,留出可用的显示空间供Lliner使用。它集中在所有屏幕上,而不是Lliner上方的空间。。。但它提供了一个很好的洞察力。背景颜色纯粹是为了获得一个可以理解的视图分布的视觉效果,除非我正在为5岁的孩子创建一个应用程序。Sit使用一个表格布局。由于我名声不好,我需要等8个小时才能发布正确的答案,到时候我会做的。