Android는 뷰 사이에 수평선을 그립니다.
다음과 같은 내 레이아웃이 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Twitter Feeds"
android:textStyle="bold" />
<ListView
android:id="@+id/list"
android:layout_width="350dp"
android:layout_height="50dp" />
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:text="FaceBook Feeds" />
<ListView
android:id="@+id/list1"
android:layout_width="350dp"
android:layout_height="50dp" />
</LinearLayout>
내 요구 사항이 그려입니다 수평 라인을 사이 TextView
와ListView
누구든지 도울 수 있습니까?
TextView
& 사이에 은회색 선이 그려집니다.ListView
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:text="FaceBook Feeds" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#c0c0c0"/>
<ListView
android:id="@+id/list1"
android:layout_width="350dp"
android:layout_height="50dp" />
새로운 경량보기 Space
를 사용하여 구분선을 그려야합니다. Space
대신을 사용하면 레이아웃이 더 빨리로드됩니다 View
.
수평 분할기 :
<android.support.v4.widget.Space
android:layout_height="1dp"
android:layout_width="match_parent" />
수직 분할기 :
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp" />
배경을 추가 할 수도 있습니다.
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
사용 예 :
....
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="One"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three"/>
....
사용 Space
하려면 build.gradle에 종속성을 추가해야합니다 .
dependencies {
compile 'com.android.support:support-v4:22.1.+'
}
문서 https://developer.android.com/reference/android/support/v4/widget/Space.html
분리하려는 뷰 사이의 레이아웃에 다음과 같이 추가하십시오.
<View
android:id="@+id/SplitLine_hor1"
android:layout_width="match_parent"
android:layout_height= "2dp"
android:background="@color/gray" />
도움이되기를 바랍니다 :)
Creating it once and using it wherever needed is a good idea. Add this in your styles.xml:
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
and add this in your xml code, where a line divider is needed:
<View style="@style/Divider"/>
Originally answered by toddles_fp to this question: Android Drawing Separator/Divider Line in Layout?
Try this
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="?android:attr/listDivider"/>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" />
You can put this view between your views to imitate the line
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0"/>
In each parent LinearLayout
for which you want dividers between components, add android:divider="?android:dividerHorizontal"
or android:divider="?android:dividerVertical
.
Choose appropriate between them as per orientation of your LinearLayout
.
Till I know, this resource style is added from Android 4.3.
Try this
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
Try this works for me
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/tw_composer />
A View whose background color you can specify would do (height=a few dpi). Looked in real code and here it is:
<LinearLayout
android:id="@+id/lineA"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
Note that it may be any kind of View
.
----> Simple one
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#c0c0c0"
android:id="@+id/your_id"
android:layout_marginTop="160dp" />
If you does not want to use an extra view just for underlines. Add this style on your textView
.
style="?android:listSeparatorTextViewStyle"
Just down side is it will add extra properties like
android:textStyle="bold"
android:textAllCaps="true"
which you can easily override.
참고URL : https://stackoverflow.com/questions/19115332/android-draw-a-horizontal-line-between-views
'Programing' 카테고리의 다른 글
Android : 체크 박스 리스너 (0) | 2020.08.27 |
---|---|
급여 테이블에서 세 번째 또는 n 번째 최대 급여를 찾는 방법은 무엇입니까? (0) | 2020.08.27 |
자바 스크립트에서 브라우저 간 플래시 감지 (0) | 2020.08.27 |
MVC Razor 뷰 중첩 foreach의 모델 (0) | 2020.08.27 |
트위터 부트 스트랩 버튼 스타일링 (0) | 2020.08.27 |