導航:首頁 > 操作系統 > android分割線顏色

android分割線顏色

發布時間:2022-06-20 06:49:58

android listview每條記錄下都有一條分隔線,如何去掉分割線

可以用下面幾種方法
1,設置android:divider="@null"也即不為listview設置分割線
2,設置android:divider="@android:color/transparent"就是分割線透明,相當於沒有分割線,不過分割線還是會佔一些位置
3,設置android:dividerHeight="0dp"設置分割線高度為0,也就沒有分割線了

Ⅱ android listView底部分割線怎麼顯示出來

1. ListActivity有這條底部分割線。
2.在Activity中只有listview,沒有別的控制項的話也會有。
其實ListActivity也是一個Activity,只不過在其中使用了SetContentView(listView)方法設置了一個listView作為其顯示的View而已。所以結論就是只要這個activity調用了SetContentView(listView)就會有這條底部分割線。
那麼什麼情況下才不會有這條分割線呢?在Activity中如果調用setContentView(View)而ListView只是內嵌入到這個View的話有可能會沒有這條分割線
在一個Activity中只有一個ListView,把它的layout_height修改為fill_parent,最底下的線是可以顯示出來的,但修改為wrap_content就顯示不出來了,(一般情況我們把高度都是設置成fil_parent的)
在一個Activity中最上邊和最下邊都有個TextView,ListView夾在中間,把它的layout_height為fill_parent或者wrap_content,最底下的線是可以顯示出來的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 現在無此屬性

android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/mTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="HelloWorldTop"
/>
<TextView
android:id="@+id/mBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="HelloWorldBottom"
/>
<ListView
android:id="@+id/mList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mTop"
android:layout_above="@id/mBottom"/>
</RelativeLayout>

Ⅲ androidstudio怎麼設置分割線

android studio設置分割線的話,在xml布局文件裡面,你可以使用view,這是寬度或者高度為1px就行。

Ⅳ android中設置分隔線有幾種方法

方法一

也是我們常用的方法,可以在按鈕間添加作為分割線的View,設定好View的寬度高度和顏色值後插入按鈕的布局間。

View的樣式如下:

android:layout_height="fill_parent"

android:layout_width="1dp"

android:background="#90909090"

android:layout_marginBottom="5dp"

android:layout_marginTop="5dp"

/>

Ⅳ android menu 分割線怎麼實現,箭頭所指的地方

用一個view即可,高度自定,寬度1dp ,顏色自定(background設置一個顏色比如:#50FFFFFF 50代表透明度,6個F代表白色)。 上下居中,再定義一下外邊距即可。

Ⅵ android 如何設置listview的分割線為虛線

樓主,你的這個問題我遇到過,並且用另一種方式解決了。
首先告訴你,listview的分割線不能設置為虛線,你也知道關於它的兩個屬性:
android:divider="#FFCC00"(或者android:divider="@color/divider_color")
android:dividerHeight="4px"
一個是設置顏色,一個是設置高度。沒法設置為虛線。
---------------------------
我的做法是這樣的!比較暴力,但能解決問題。
讓美工給你做一個虛線的圖!保存為 xuxian.png
然後再用android:divider="@drawable/xuxian",把它設置為這個圖。看上去就是個虛線了。至於效果,讓美工和你一起再慢慢細調。
結論是:很絕望。目前只有這一個辦法,可以解決你的問題。
手動打字,非ctrl+c / ctrl+v之流。但願能幫到你

Ⅶ android 19 listview分割線默認顏色值是多少

剛剛在android19 SDK下寫了一個listview 然後用ps獲取到listview分割線的顏色值 十六進制:d8d8d8 RGB:216 216 216

Ⅷ android怎麼設置listview中的每個item之間的分割線

android:divider="@null" 這是去掉分割線
android:divider="#00000000"這是設置分割線透明,也相當於去掉分割線
android:divider="#fffff" 這是設置分割線顏色
android:dividerHeight="1px" 設置分割線高度

Ⅸ 如何設置actionbar讓分割線改變顏色

android 布局 layout relativelayout

除了沉浸模式外,Android 4.4還有新的API,能使應用內的狀態欄和虛擬按鈕透明。其他更多的Android 4.4 APIs可以看這里。

如果要使應用內的狀態欄和虛擬按鈕變成透明有兩種方法。

一種是代碼方式:

?1

2

3Window window = getWindow();

window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

另外一種是使用兩個新的主題風格:

Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor。

但是這種方式只支持Android4.4以上系統,所以為了保持兼容性,我們還是採用代碼方式比較好。只需要先判斷,如果是4.4以上系統才啟用代碼。

開啟後上下系統欄都透明了。

但是如果應用本身是帶有actionbar或者標題欄的話會就會變得比較尷尬,內容會在上面露出來。這個時候需要在布局文件里加入android:fitsSystemWindows="true"。

android:id="@+id/layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#c8c8c8" >

android:id="@+id/listview"

android:layout_width="match_parent"

android:layout_height="match_parent" />

但是這樣的話內容就不能從透明的虛擬按鈕下穿過,沒原來那麼好看。我們可以按照以前一樣把根布局設置一個高度為系統欄高度和ActionBar高度的內邊距就可以。

同時關於獲取ActionBar和狀態欄的高度,發現用原來的方法有時候會獲取的值為0。自己google找了一下,找到兩個前輩提供的獲取高度方法,獲取ActionBar高度,獲取狀態欄高度。

8if (android.os.Build.VERSION.SDK_INT > 18) {

Window window = getWindow();

window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

//設置根布局的內邊距

RelativeLayout relativeLayout = (RelativeLayout)
findViewById(R.id.layout);

relativeLayout.setPadding(0, getActionBarHeight()+getStatusBarHeight(), 0,
0);

}

27// 獲取手機狀態欄高度

public int getStatusBarHeight() {

Class c = null;

Object obj = null;

Field field = null;

int x = 0, statusBarHeight = 0;

try {

c = Class.forName("com.android.internal.R$dimen");

obj = c.newInstance();

field = c.getField("status_bar_height");

x = Integer.parseInt(field.get(obj).toString());

statusBarHeight = getResources().getDimensionPixelSize(x);

} catch (Exception e1) {

e1.printStackTrace();

}

return statusBarHeight;

}

// 獲取ActionBar的高度

public int getActionBarHeight() {

TypedValue tv = new TypedValue();

int actionBarHeight = 0;

if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))//
如果資源是存在的、有效的

{

actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
getResources().getDisplayMetrics());

}

return actionBarHeight;

}

接下來,因為我自己寫的一些應用是暗色的主題的,會導致透明的狀態欄和ActionBar顏色不太協調。看到有一些應用是把狀態欄的顏色設置成和ActionBar一樣,這種解決方法也不錯。

具體是怎麼實現的也不太清楚,我自己猜測寫了一個差不多狀態欄。我是直接在根視圖加入一個高度為狀態欄高度的TextView,背景設置為和ActionBar一樣。具體代碼如下:

8// 創建TextView

TextView textView = new TextView(this);

LinearLayout.LayoutParams lParams = new
LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, getStatusBarHeight());

textView.setBackgroundColor(Color.parseColor("#3F9FE0"));

textView.setLayoutParams(lParams);

// 獲得根視圖並把TextView加進去。

ViewGroup view = (ViewGroup) getWindow().getDecorView();

view.addView(textView);

在模擬器上看還行,但是在實際的手機當中總感覺ActionBar有點過大,所以我在背景色里加入了一些漸變,在實體手機中就比較好看一點,不會覺得ActionBar太寬了。

android:startColor="#c8c8c8"

android:endColor="#3F9FE0"

android:angle="270"

android:type="linear"/>

Ⅹ 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"

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

閱讀全文

與android分割線顏色相關的資料

熱點內容
程序員開車賣服裝 瀏覽:393
快速記憶法pdf 瀏覽:516
java定義異常類 瀏覽:707
的運行命令 瀏覽:585
24v電動駐車空調壓縮機 瀏覽:840
老程序員編程步驟 瀏覽:305
物理去除加密軟體 瀏覽:227
匯編語言可調試編譯器 瀏覽:447
jpeg如何轉成pdf 瀏覽:841
微機室為什麼有伺服器 瀏覽:657
安卓手機怎麼打語音電話不斷網 瀏覽:458
單片機匯編頭文件 瀏覽:946
juniper命令行 瀏覽:68
程序員咨詢銷售工作怎麼樣 瀏覽:782
蘋果文件伺服器是什麼 瀏覽:180
企業透明加密軟體有監視功能嗎 瀏覽:494
桌面的運行命令 瀏覽:10
主流廠商伺服器維護流程是什麼 瀏覽:807
壓縮棉的被子先洗洗在用 瀏覽:242
批處理bat代碼和文件夾 瀏覽:298