【发布时间】:2017-05-14 15:11:10
【问题描述】:
我有这样的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
>
<LinearLayout
android:id="@+id/relativeLayoutforPRICE"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView$_points_to_win"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Points to win"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/spinner$_points_to_win"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
目前看起来是这样的:
我想将 Spinner 移动到 LinearLayout 的右侧。我尝试使用:
android:gravity="right"
和
android:gravity="end"
和
android:layout_gravity="right"
和
android:layout_gravity="end"
但这没有帮助。是否有任何其他选项可以将其向右移动? 同样重要的是,我希望将父布局保持为线性(垂直方向),将当前布局保持为线性(水平方向)。
【问题讨论】:
-
你可以在你的
TextView中使用layout_weight="1" -
如果您将
android:layout_gravity="right"设置为 Spinner,请改用 FrameLayout -
@ChiragSavsani,你说的很有趣!不过,我想知道是否有任何方法可以让这个微调器尽可能小,并且只将它移动到右侧。
-
@withparadox2,就像我说的,我想保持它为 LinearLayout。
-
@Tomas 你能试试我在答案中提到的代码吗?