簡體   English   中英

gridLayout中的搜尋欄超出邊距

[英]seekbar in gridLayout out of margin

我正在開發一個Android應用程序,其中有一個在tts上帶有一些控件的UI。 我在這樣的xml文件中定義了布局:

  <GridLayout
    android:id="@+id/vlmPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btnPanel"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true">

    <TextView
        android:id="@+id/volumeLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_gravity="center_vertical"
        android:layout_row="0"
        android:text="Volume:" />

    <SeekBar
        android:id="@+id/volume"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_columnWeight="1"
        android:layout_gravity="center_vertical"
        android:layout_row="0"/>

    <TextView
        android:id="@+id/pitchLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_column="0"
        android:layout_gravity="center_vertical"
        android:layout_row="2"
        android:text="Pitch:" />

    <SeekBar
        android:id="@+id/pitch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_gravity="center_vertical"
        android:layout_row="2" />

    <TextView
        android:id="@+id/rateLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_column="0"
        android:layout_gravity="center_vertical"
        android:layout_row="3"
        android:text="Rate:" />

    <SeekBar
        android:id="@+id/rate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_column="1"
        android:layout_gravity="center_vertical"
        android:layout_row="3" />
</GridLayout>

問題是搜尋欄超出了邊距,我無法解決此問題。

嘗試這個

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
     <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
             <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/volumeLabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_column="0"
                    android:layout_row="0"
                    android:text="Volume:" />

                <SeekBar
                    android:id="@+id/volume"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center_vertical"
                    android:layout_row="0"
                    android:layout_weight="1"
                />
            </TableRow>
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/pitchLabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_column="0"
                    android:layout_gravity="center_vertical"
                    android:layout_row="2"
                    android:text="Pitch:" />

                <SeekBar
                    android:id="@+id/pitch"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_gravity="center_vertical"
                    android:layout_row="2"
                    android:layout_weight="1"/>
                </TableRow>
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/rateLabel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_column="0"
                    android:layout_gravity="center_vertical"
                    android:layout_row="3"
                    android:text="Rate:" />

                <SeekBar
                    android:id="@+id/rate"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_gravity="center_vertical"
                    android:layout_row="3" 
                    android:layout_weight="1"/>
                </TableRow>            
        </TableLayout>
</LinearLayout>

我已將布局更改為嘗試使用此布局來解決您的問題的方式。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM