【问题标题】:Spinner alignment in TableViewTableView 中的微调器对齐
【发布时间】:2014-11-02 16:34:07
【问题描述】:

我正在尝试在 Android 的 2 列表中右对齐微调器。

这是我迄今为止尝试过的:

<TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/object_background">

        <TableRow>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Test"/>

            <Spinner
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:gravity="right"/>
        </TableRow>

【问题讨论】:

    标签: android spinner right-align


    【解决方案1】:

    1) 在你的 textView 组件中使用 android:layout_width="0dp"android:layout_weight="1"

    2) 将 android:layout_width="match_parent" 设置为您的 tableRow。

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Test" />
    
            <Spinner
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </TableRow>
    </TableLayout>
    

    输出:

    【讨论】:

      【解决方案2】:

      我不确定这是否适用于表格,但您可以尝试使用重力左/右的权重(尽管这会显示嵌套权重不利于性能的警告)但这是我暂时使用的使用水平线性布局:

      <TextView
                  android:id="@+id/TextViewID"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_gravity="left"
                  android:layout_weight="0.4"
                  android:text="@string/TextView" />
      
              <Spinner
                  android:id="@+id/SpinnerID"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_gravity="right"
                  android:layout_weight="0.6" />
      

      以上将我的微调器对齐到我的文本视图的右侧

      【讨论】:

        猜你喜欢
        • 2015-08-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-11
        • 2017-04-07
        • 1970-01-01
        • 2012-11-11
        • 2012-05-24
        相关资源
        最近更新 更多