2017-08-11 38 views
-1

我有一个具有背景图像的线性布局。 我需要在创建线性布局之前滚动视图。 我这样做后,我的线性布局图像变得越来越紧张。 你能帮助我创造我的形象,所以它不会被拉伸?如何实现该背景图像不会在线性布局上得到延伸

这是我上的.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:fillViewport="true"> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height= "wrap_content" 
    android:gravity="center_horizontal" 
    android:background="@drawable/bg_image_login" 
    android:orientation="vertical" 
    android:windowSoftInputMode="stateVisible|adjustResize" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.fania.suara_project.LoginActivity"> 

    <ImageView 
     android:id="@+id/haha" 
     android:background="drawable/bg_image_login" 
     android:scaleType="fitXY" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 


</LinearLayout> 

代码请帮助我。谢谢:)

+0

为何在linearlayout和imageview中使用相同的图像“drawable/bg_image_login”。 –

+1

尝试从android:scaleType =“CENTER_CROP”替换android:scaleType =“fitXY” –

回答

1

放滚动视图背景代替的LinearLayout的

android:background="@drawable/bg_image_login"