導航:首頁 > 操作系統 > androidxml分割線

androidxml分割線

發布時間:2023-03-09 17:48:11

1. android 在xml中設置textview 下劃線

只知道在代碼中設置下劃線:textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
真沒用過在xml中設置下劃線的屬性,如果只是要那種效果可以在TextView控制項下面翻一個view當線使用。

2. android分割線設置怎麼弄

方法一也是我們常用的方法,可以在按鈕間添加作為分割線的View,設定好View的寬度高度和顏色值後插入按鈕的布局間。
View的樣式如下:
<View
android:layout_height="fill_parent"
android:layout_width="1dp"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>

相應的布局如下:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:orientation="horizontal">

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Yes"
android:layout_weight="1"
android:id="@+id/button1"
android:textColor="#00b0e4" />

<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator1" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="No"
android:layout_weight="1"
android:id="@+id/button2"
android:textColor="#00b0e4" />

<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator2" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Neutral"
android:layout_weight="1"
android:id="@+id/button3"
android:textColor="#00b0e4" /></LinearLayout>

方法二
通過LinearLayout指定的divider的屬性來插入分隔符,類似於Listview的效果。這種方法的好處在於縮減布局代碼量,同時在button數量未知的情況下能更方便的進行顯示。但是這種方法只適用API版本11以上的機型。
使用方法也很簡單,先創建分隔線的樣式文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="1dp" />
<solid android:color="#90909090" /></shape>

再在布局文件中引用
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:divider="@drawable/separator"
android:showDividers="middle"
android:orientation="horizontal">

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Yes"
android:layout_weight="1"
android:id="@+id/button1"
android:textColor="#00b0e4" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="No"
android:layout_weight="1"
android:id="@+id/button2"
android:textColor="#00b0e4" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Neutral"
android:layout_weight="1"
android:id="@+id/button3"
android:textColor="#00b0e4" /></LinearLayout>

最主要的代碼如下
android:divider="@drawable/separator"
android:showDividers="middle"

當然分隔線的樣式也可以用圖片來替代,這就看項目的需求了。

閱讀全文

與androidxml分割線相關的資料

熱點內容
一個普通程序員能幹多久 瀏覽:934
adobe的PDF轉換器 瀏覽:853
單片機數字碼表匯編 瀏覽:477
單片機開發用的軟體 瀏覽:151
程序員8個演算法題 瀏覽:400
php題庫系統 瀏覽:221
王牌戰爭文明重啟選什麼伺服器 瀏覽:653
簡述對稱加密法 瀏覽:658
c語言數學編程 瀏覽:990
F1B命令 瀏覽:630
cs命令快捷鍵 瀏覽:852
阿里雲購買伺服器如何用現金支付 瀏覽:691
pythontime等待 瀏覽:988
單片機串列通信方式 瀏覽:498
android表格demo 瀏覽:278
安卓怎麼讓相冊不顯示網頁 瀏覽:314
php文件系統源碼 瀏覽:727
易信java 瀏覽:501
北侖二級壓縮螺桿機 瀏覽:63
加密路線免費入口 瀏覽:759