2

アプリケーションのレイアウトの設計に問題があります。これは私が取得しようとしているものです:

=========================================================
|  =============   ================   ================  |
|  |           |   | LinearLayout |   | LinearLayout |  |
|  |           |   | ============ |   | ============ |  |
|  |           |   | | TextView | |   | | TextView | |  |
|  | ImageView |   | ============ |   | ============ |  |
|  |           |   | ============ |   | ============ |  |
|  |           |   | | TextView | |   | | TextView | |  |
|  |           |   | ============ |   | ============ |  |
|  |           |   | ============ |   | ============ |  |
|  |           |   | | TextView | |   | | TextView | |  |
|  |           |   | ============ |   | ============ |  |
|  =============   ================   ================  |
=========================================================

これは私がこれまで行ってきた方法です (明確にするために、ID と別のものを削除しました)。

<?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="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical" >


    <ImageView
        android:contentDescription="@string/logo"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="left|center_vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="right|center_vertical"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true" />

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true" />

    </LinearLayout>

</LinearLayout>

私の問題は、高解像度の画像を使用し、それらを縮小して、その隣の最高の線形レイアウトに合わせたいということです。私の考えは、Android が低 dpi のデバイスで画像を縮小するようにすることです。したがって、すべてのプラットフォームで同じ画像とレイアウトを使用します。

現在、メインコンテナの高さは画像の高さと同じになります。私が望むのは、メインコンテナの高さを「最も高い」線形レイアウトと同じにし、メインコンテナに合わせてイメージビューを強制的に縮小することです。

何か案は?

ありがとう!

PD: 英語ですみません!:$

4

3 に答える 3

0
    LinearLayout ll = (LinearLayout)findViewById(R.id.your_linearlayout);

    int llHeight = ll.getHeight();

    ImageView iv = (ImageView)findViewById(R.id.your_imageview);

    LayoutParams ivParams = ((ImageView)findViewById(R.id.your_imageview)).getLayoutParams();

    ivParams.height = llHeight;

    iv.setLayoutParams(ivParams );
于 2013-07-23T04:32:51.020 に答える
0

以下のコードを実装してみてください。

下の画像を参照してください。

これが以下のコードのスクリーンショットです

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:weightSum="1"
          android:background="#FFFFFF"
          android:layout_height="match_parent">

<LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:background="#000000"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:weightSum="5"
        android:orientation="horizontal">

    <ImageView
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_weight="0.9"
            android:background="@drawable/black"/>

    <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_weight="1.15">
    </LinearLayout>
    <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_weight="0.9"
            android:weightSum="4"
            android:orientation="vertical">

        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="Linear Layout"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
    </LinearLayout>

<LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_weight="1.15">
    </LinearLayout>
    <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_weight="0.9"
            android:weightSum="4"
            android:orientation="vertical">
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="Linear Layout"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:text="TextView"
                android:gravity="center_vertical|center_horizontal"
                android:textSize="25dp"/>
    </LinearLayout>
</LinearLayout>

于 2013-07-23T05:38:26.640 に答える