나는 두 개의 ListViews
(leftList, rightList)이 있습니다. 나는 또한 하나의 TextView
을 두 행 뷰로 사용한다. 직사각형 드로어 블 모양이 있고 TextView
의 배경으로 설정했습니다.android - 프로그래밍 방식으로 모서리 반경을 설정하는 방법은 무엇입니까?
이 모양을 변경하고 왼쪽에 둥근 모서리가 있습니다.
내가 뭘하려 :
GradientDrawable gradientDrawable = new GradientDrawable();
// gradientDrawable.setCornerRadius(30);
((GradientDrawable)gradientDrawable.mutate()).setCornerRadius(30);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
viewHolderPattern.digits.setBackground(gradientDrawable);
}
내가 설정하고 setBackgroundRescource
와 텍스트 뷰에 있지만 여전히 작동하지 않았 음을 설정 오른쪽 모서리 반경 당김에 새로운 레이아웃을 만들었습니다.
나는 모두의 ListView에 항목으로 사용하는 텍스트 뷰
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/digitsTextView"
android:textSize="15dp"
android:paddingTop="7dp"
android:paddingBottom="8dp"
android:fontFamily="monospace"
android:textColor="@color/selected_items"
android:background="@drawable/digital_text_shape">
</TextView>
모양 레이아웃 digital_text_shape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/orange" />
<solid android:color="@color/orange" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="20dp"
android:topRightRadius="0dp"
/>
<padding
android:bottom="0dp"
android:left="20dp"
android:right="0dp"
android:top="0dp" />
</shape>
왼쪽 목록과 오른쪽 목록
<!-- Left ListView -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:id="@+id/left_listView"
android:divider="@android:color/transparent"
android:dividerHeight="0.1sp"
android:choiceMode="singleChoice"
>
</ListView>
</LinearLayout>
<!-- Right ListView -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ListView
android:id="@+id/right_listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="0.1sp"
android:choiceMode="singleChoice"
>
</ListView>
</LinearLayout>
가 알다시피, TextViews 당신은 단지 /> 그들을 clsoe 수 있습니다. 내부에 무언가가있는 경우를 제외하고 마지막에 두 번째 태그가 필요하지 않습니다. – Zoe
왜 다른 xml을 사용하는 다른 뷰 소유자가 없습니까? 리사이클 러 뷰는 이와 같은 복잡한리스트에 대한리스트 뷰를 사용하려는 많은 노력처럼 보입니다. 리사이클러는 이러한 풍부하고 복잡한리스트를 목표로합니다. –
두 개의 다른 TextView 백그라운드 XML 파일을 만들면 어떻게 될까요? 하나는 왼쪽이고 다른 하나는 오른쪽입니다. 그리고 왼쪽 뷰에있는 경우 : textView.setBackground (getResources(). getDrawable (R.drawable.leftTextViewBackground)); 오른쪽 목록보기에서 : textView.setBackground (getResources(). getDrawable (R.drawable. rightTextViewBackground)); ? – DadoZolic