2

私はこのコードを持っています:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:hint="@string/tip_value" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:hint="@string/tip_value" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:hint="@string/tip_value" />

</LinearLayout>

上記のコードの結果

EditText の高さに合わせて textSize を調整するにはどうすればよいですか?

大文字が編集テキストの高さ全体に及ぶことを意味します(linearLayoutのために異なるサイズになる可能性があります)

前もって感謝します。

4

2 に答える 2

0

内部の各ビューの高さを確認し、listViewその特定のビューのテキスト サイズを定義する必要があります。このためには、カスタム アダプタを使用してarrayまたはarrayList(またはcursor...)を に表示する必要がありlistViewます。下のカスタム アダプターで、特定のビューの正確な高さをピクセル単位で取得し、そのビューのサイズを で設定getView()できます。これに似たものでなければなりません:(私はこのコードをチェックしていません。例としてあなたのために書いています)convertView.getHeight()textViewgetView()

public View getView(int position, View convertView, ViewGroup parent) {
    .
    .
    .
    View line = convertView;
    float size = line.getHeight();
    TextView text = findViewById...
    text.setTextSize(size-20);
    return line;
}
于 2013-05-13T22:32:01.997 に答える
0

あなたの質問はこのようなものだと思います。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="please Enter" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="please Enter" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="please Enter" />
</LinearLayout>

于 2013-05-14T13:05:16.673 に答える