【问题标题】:How to apply background Image on ScrollView android如何在 ScrollView android 上应用背景图像
【发布时间】:2015-05-07 14:51:27
【问题描述】:

我想在 ScrollView 下的 Relativelayout 上应用背景图像。 图像出现在 XML 视图上,但未出现在实际设备上。

我在 Ralativelayout 上添加了 ImageView

  1.     >
    
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent" android:layout_height="match_parent"
    
            android:id="@+id/parentView"
            >
     <ImageView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:src="@drawable/cloudbg"
                />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:id="@+id/vo"
                android:layout_below="@id/relativeLayout"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="20dp"
                android:layout_height="wrap_content">
    
                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:text="XYZ"
                    />
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_marginLeft="25dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/textvo"
                    android:text="Voter Number"
                    />
    
            </LinearLayout>
    
    
           </RelativeLayout>
    </ScrollView>
    

谢谢

【问题讨论】:

  • 如果你想为相对布局提供图像,请尝试提供背景以避免图像视图
  • 你想修复背景?
  • 是的,我想修复背景
  • 你可以给background color to your parent layout

标签: android android-layout


【解决方案1】:

可以这样试试:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/cloudbg">

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="fill_parent" >

 <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:id="@+id/vo"
        android:layout_below="@id/relativeLayout"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="XYZ"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_marginLeft="25dp"
            android:layout_height="wrap_content"
            android:id="@+id/textvo"
            android:text="Voter Number"
            />

    </LinearLayout>
 </ScrollView>

【讨论】:

    【解决方案2】:

    在相对或线性布局标签中使用android:background="@drawable/background_image" 属性。

    【讨论】:

      【解决方案3】:
      Set background for scrollview
      <ScrollView
          android:id="@+id/scrollView1"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/ic_launcher" >
      
          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" >
          </LinearLayout>
      </ScrollView>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-07-14
        • 1970-01-01
        • 2013-10-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多