0

タブレットデバイス用にこのようなものをデザインしようとしています

-640x480領域(左境界)-------柔軟な空の幅--------制御領域(右境界)-

柔軟な幅は、タブレットのサイズによって異なります。スクロールペインは、モバイルデバイスでのデバッグ専用です。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <HorizontalScrollView
        android:id="@+id/scrollView12"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/ll1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#24476D" >

            <view
                android:id="@+id/dmi"
                android:layout_width="640dp"
                android:layout_height="480dp"
                android:layout_gravity="left"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="20dp"
                android:layout_weight="1"
                class="com.example.ecorailnet.DMIView"
                android:background="#8fc7ff" />

            <TextView
                android:id="@+id/empty_list_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="List view is empty"
                android:visibility="gone" />

            <view
                android:id="@+id/cpp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="20dp"
                android:layout_weight="1"
                class="com.example.ecorailnet.ControlPanel" />
        </LinearLayout>
    </HorizontalScrollView>
</ScrollView>

そして最後に、現在の状況とそれがどのように見えるべきか。

前もって感謝します

ご挨拶

4

2 に答える 2

1

ディスプレイの左側と右側に何かが必要な場合は、:を使用しますRelativeLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#24476D" >

    <view
        android:id="@+id/dmi"
        android:layout_width="640dp"
        android:layout_height="480dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_gravity="left"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        class="com.example.ecorailnet.DMIView"
        android:background="#8fc7ff" />

    <view
        android:id="@+id/cpp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_gravity="right"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        class="com.example.ecorailnet.ControlPanel" />

</RelativeLayout>

あなたが得ることができる唯一の問題は、すべてが小さな画面に収まらないということです。その場合、2つのビューはオーバーラップします。

于 2012-08-14T15:29:34.033 に答える
0

640x480pxのDMIViewが必要であると本当に確信している場合。

DMIViewのonMeasureMethodをオーバーライドしてみてください

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    this.setMeasuredDimension(640,480);
}

または、すべての高さを占める適切にスケーリングされたDMIViewが必要な場合

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
    this.setMeasuredDimension(Math.round(parentHeight * 640 / 480f),parentHeight);      
}

これらがお役に立てば幸いです。

于 2012-08-14T16:15:28.463 に答える