나는 다음과 같다리스트 뷰 할 노력하고 있어요 : alt text http://pici.se/pictures/hjFksZvLx.jpg오른쪽 및 왼쪽을 선형 또는 relativelayout으로 잘린 텍스트로 정렬합니까?
그것은 두 부분으로, 왼쪽은 왼쪽 정렬을 단일 라인과 절단을 두 textviews가 포함되어 있습니다. 오른쪽 부분도 두 개의 텍스트 뷰가 있지만 오른쪽 정렬되고 일정한 크기입니다. 주된 문제는 오른쪽 부분이 오른쪽에 정렬되지 않는다는 것입니다. 고정 폭을 사용하여 오른쪽으로 밀면 꽤 잘 작동하지만 가로 모드에서는 좋지 않습니다.
나는 그것이 간단해야한다고 생각했다. 하지만 그렇지 않았습니다. 나는 무게 속성을 조롱 한
<?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="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:id="@+id/L1"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:layout_width="0dip">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:text="Long text Long text Long text Long text Long text Long text Long text" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:text="Short text" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:id="@+id/L2"
android:layout_gravity="top|right"
android:layout_height="fill_parent"
android:layout_weight="0.2"
android:layout_width="0dip">
<TextView
android:id="@+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="12:12" />
<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="64%"
android:layout_gravity="right" />
</LinearLayout>
</LinearLayout>
, 그러나 도움이하지 않는 것 :
우선 내가있는 LinearLayout로했습니다. 오른쪽 부분은 오른쪽에 정렬되지 않습니다. 오른쪽 부분이 제대로 오른쪽으로 정렬되지 않고, 여기<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:id="@+id/text1"
android:layout_height="wrap_content"
android:lines="1"
android:scrollHorizontally="true"
android:layout_alignParentTop="true"
android:text="Long text Long text Long text Long text Long text Long text Long text"
android:layout_alignParentLeft="true"
android:ellipsize="end"
android:layout_width="275dp" />
<TextView
android:id="@+id/text2"
android:layout_height="wrap_content"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:text="Long text Long text Long text Long text Long text Long text Long text"
android:layout_below="@+id/text1"
android:layout_alignParentLeft="true"
android:layout_width="275dp" />
<TextView
android:id="@+id/text3"
android:layout_height="wrap_content"
android:text="12:12"
android:layout_gravity="right"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@+id/text1"
android:layout_width="40dp"
android:layout_alignRight="@+id/text4" />
<TextView
android:id="@+id/text4"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="64%"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@+id/text2"
android:layout_width="40dp" />
</RelativeLayout>
같은 문제를, 나는 안드로이드의 정적 크기를 사용해야합니다 : :
그리고 나는 RelativeLayout의와 시도에 그것을 밀어 layout_width를 반대편. 정적 크기를 사용하지 않으면 텍스트가 서로 잘립니다.
감사합니다 ... 저는 Linearlayout을 추가로 피하기를 희망했지만, 이것이 유일한 방법이었습니다. – droidgren
RelativeLayout에 LinearLayout을 래핑 할 때의 요점은 무엇입니까? LinearLayout은 이제 RelativeLayout의 유일한 자식이며 부모는 아마도 제거 될 수 있습니까? –
@GlennBech :'RelativeLayout' 안에는 LinearLayout뿐만 아니라 더 많은 위젯들이 있습니다. – Macarse