2

2 つのテキスト ビューを 1 行に配置する必要があります。2 番目のものは最初のものの隣に配置する必要があります (図 1 に示すように)。

私の問題は、最初のテキストビューのテキストが長い可能性があるため、楕円にする必要があることです。2 番目のテキスト ビューでテキスト全体を読むことができるように、必要なだけのスペースが必要です。図 2 はそれを示しています。

Android 組み込みのレイヤーを使用してそれを達成することは可能ですか、それともカスタム ビューを作成する必要がありますか?

スクリーンショット

4

2 に答える 2

0

内部レイアウトを作成し、android:weightSum="100"属性を使用します。次に、この内部レイアウトに 2 つのテキスト ビューを配置し、android:layout_weight="50"各テキスト ビューに属性を追加します。

于 2012-12-12T20:09:56.733 に答える
0

このようなことを試してください

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:ellipsize="end"
    android:text="A long long text" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="A long text" />

</LinearLayout>

よろしく

于 2012-12-12T21:09:43.533 に答える