TextView可选择和可绘制的背景

时间:2016-01-27 14:32:20

标签: android android-layout textview android-button android-styles

我是TextView。我需要使它可点击,白色和"可选效果",此外我需要它有一个矩形白色边框,假一个按钮边框:

TextView example

<TextView
    android:id="@+id/test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?android:selectableItemBackground"
    android:background="@drawable/white_empty_rectangle"
    android:clickable="true"
    android:padding="10dp"
    android:text="Test"
    android:textColor="@color/white" />

我无法设置两个背景属性......我怎么能以某种方式&#34;交叉&#34;两个属性?

编辑:我只需要矩形的边框,所以它是&#34;空&#34;,我应该看到TextView背后的背景颜色。

2 个答案:

答案 0 :(得分:1)

检查此答案https://stackoverflow.com/a/5295522/4848308您应该使用背景选择器。 这个实现边界线背景https://stackoverflow.com/a/3496310/4848308

我希望它有所帮助!

答案 1 :(得分:0)

这个怎么样?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="menuitems">
        <table class="toolbaritems">
            <tbody class="sortable">
                <tr id="row1">
                    <td>
                        <button type="button" class="up_arrow">UP</button>
                    </td>
                    <td>
                        <button type="button" class="down_arrow">DOWN</button>
                    </td>
                    <td>
                        <input type="text" value="1" />
                    </td>
                    <td>
                        <select>
                            <option value="1" selected>1</option>
                        </select>
                    </td>
                    <td>
                        <select>
                            <option value="1a" selected>1a</option>
                        </select>
                    </td>
                </tr>
                <tr id="row2">
                    <td>
                        <button type="button" class="up_arrow">UP</button>
                    </td>
                    <td>
                        <button type="button" class="down_arrow">DOWN</button>
                    </td>
                    <td>
                        <input type="text" value="2" />
                    </td>
                    <td>
                        <select>
                            <option value="2" selected>2</option>
                        </select>
                    </td>
                    <td>
                        <select>
                            <option value="2a" selected>2a</option>
                        </select>
                    </td>
                </tr>
                <tr id="row3">
                    <td>
                        <button type="button" class="up_arrow">UP</button>
                    </td>
                    <td>
                        <button type="button" class="down_arrow">DOWN</button>
                    </td>
                    <td>
                        <input type="text" value="3" />
                    </td>
                    <td>
                        <select>
                            <option value="3" selected>3</option>
                        </select>
                    </td>
                    <td>
                        <select>
                            <option value="3a" selected>3a</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>