1

私が開発しているアプリには、さまざまなデバイスのサイズに合わせてスケーリングしたい背景画像があります。最も重要なのは、幅に合わせることです。背景が黒にフェードアウトするので、メイン ビューに黒の背景を永続的に表示できます。

background.xml ファイルを作成しましたが、現時点では res フォルダーに 800x1280 px グラフィックの特大背景画像しかありません。Samsung Galaxy S3 の設定を使用して AVD でアプリを実行すると、背景の幅が画面全体に収まりませんが、残りのコントロールは画面に合わせて調整されます。

これが私の見解の始まりです:

<ScrollView android:id="@+id/MainScrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="#000000" 
    android:orientation="vertical"
    android:fillViewport="true">

<LinearLayout
    android:id="@+id/lineLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:background="@drawable/background"
    android:orientation="vertical"> 

私の background.xml は次のようになります。

<bitmap xmlns:android="http://schemas.android.com/apk/res/android" 
android:src="@drawable/mainappbg" 
android:gravity="top|left" android:filter="true" android:dither="true" />

誰かが助けてくれることを願っています。

ありがとう

私はこれを試しました。背景として挿入された画像がありますが、TasksButton と ServiceRapportButton のみが表示され、残りのコンテンツは消えます。

<ScrollView android:id="@+id/MainScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:background="#000000" 
android:orientation="vertical"
android:fillViewport="true">

<RelativeLayout 
   android:layout_width="fill_parent" 
   android:layout_height="fill_parent">
  <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:src="@drawable/mainappbg"/>

<LinearLayout
android:id="@+id/lineLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
     android:layout_height="85dp">
   <Button android:id="@+id/TasksButton" android:layout_width="wrap_content"      android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="5dp" android:layout_marginTop="5dp" android:background="@drawable/opgaver" android:onClick="TasksClickHandler" android:textSize="12sp"/>
   <Button android:id="@+id/ServiceRapportButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="15dp" android:layout_marginTop="40dp" android:background="@drawable/rapport" android:onClick="ServiceRapportClickHandler" android:textSize="12sp"/>       
</RelativeLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/tableLayout1">
      <Button android:id="@+id/LineButton" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/lines" android:onClick="LineClickHandler" android:textSize="12dp"/>        
      <Button android:id="@+id/ServiceButton" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/service" android:textSize="12dp" android:onClick="ServiceClickHandler"></Button>
      <Button android:id="@+id/NavigationButton" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/navigate" android:textSize="12dp" android:onClick="NavigateClickHandler"></Button>         
</LinearLayout>

編集、スクリーンショットを追加、これらのコントロールの背後に背景を配置したい: アプリ画面のスクリーンショット

4

1 に答える 1

0

LinearLayout( )の唯一の目的が@id/lineLayout1bgコンテナとして機能することである場合は、達成したいスケーリング結果に一致するようにImageViewset android:scaleTypeに置き換えます。

編集

それをRelativeLayoutレイアウトでラップし、ImageViewをBGコンテナとして配置します。

<ScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/MainScrollView"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" 
   android:background="#000000" 
   android:orientation="vertical"
   android:fillViewport="true">

   <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent">
      <ImageView 
          android:id="@+id/imageView1" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:src="@drawable/beta_bg_drawable"/>

        <LinearLayout 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:background="#5500ff00" 
            android:orientation="vertical">
        </LinearLayout>

   </RelativeLayout>

</ScrollView>
于 2012-11-24T14:10:00.307 に答える