Фоновое изображение в Linearlayout - PullRequest
2 голосов
/ 13 мая 2011

Я устанавливаю изображение для фона линейного макета, который я использую.Проблема, которую я получаю, это белая граница чуть ниже строки заголовка.Если я установлю цвет фона, белая рамка не появится.Кто-нибудь знает, что может быть причиной этого.

background image problem

Я загружаю некоторый контент динамически, но вот XML

<?xml version="1.0" encoding="utf-8"?>
<android.gesture.GestureOverlayView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gestures"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gestureStrokeType="single"
    android:eventsInterceptionEnabled="true"
    android:orientation="vertical"
    android:uncertainGestureColor="#00000000"
    android:gestureColor="#00000000">
<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="20dip"
    android:background="@drawable/background">
<!--     android:background="@drawable/background"> -->


    <TextView 
        android:id="@+id/item_text"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:layout_gravity="center"
        android:text="@string/item_text"
        android:textColor="#fffafa"
        android:layout_width="wrap_content"
        android:textStyle="bold"
        android:paddingBottom="10dip"/>

    <LinearLayout
        android:id="@+id/photoLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="20dip"/>     

     <LinearLayout android:id="@+id/LinearLayoutDynamic"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dp"
        android:orientation="vertical"
        android:background="@drawable/my_border">

     </LinearLayout>

     <TextView 
        android:id="@+id/item_text1"
        android:layout_height="wrap_content"
        android:paddingTop="20dip"
        android:paddingBottom="10dip"
        android:textSize="16sp"
        android:layout_gravity="center"
        android:text="Besonderheiten"
        android:textColor="#fffafa"
        android:layout_width="wrap_content"
        android:textStyle="bold"/>

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

        android:orientation="vertical"
        android:background="@drawable/my_border">

        <RelativeLayout
            android:id="@+id/LinearLayout"
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:orientation="horizontal">   


            <TextView 
                style="@style/CodeFont"
               android:id="@+id/item_wasteDisposal"
               android:text="@string/item_wasteDisposal"
               android:textSize="14sp"
               android:singleLine="true"/>  

            <ImageView 
                android:layout_height="wrap_content"  
                android:layout_width="wrap_content" 
                android:id="@+id/wasteDisposalImage"
                android:layout_toRightOf="@id/item_wasteDisposal"
                android:padding="5dp"/>

            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/wasteDisposalImage"
                android:layout_width="fill_parent"/>


            <ImageView
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content" 
                android:id="@+id/internetImage"
                android:layout_below="@id/wasteDisposalImage"
                android:layout_alignLeft="@id/wasteDisposalImage"
                android:padding="5dp"/>

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_internet"
                android:text="@string/item_internet"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/internetImage"
                android:layout_below="@id/wasteDisposalImage"/>

            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/internetImage"
                android:layout_width="fill_parent"/>


            <ImageView 
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content"
                android:id="@+id/overnightStayImage"
                android:layout_below="@id/internetImage"
                android:layout_alignLeft="@id/internetImage"
                android:padding="5dp"/>

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_overnightStay"
                android:text="@string/item_overnightStay"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/overnightStayImage"
                android:layout_below="@id/internetImage"/>  

                            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/overnightStayImage"
                android:layout_width="fill_parent"/>

            <ImageView 
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content" 
                android:id="@+id/toiletImage"
                android:layout_below="@id/overnightStayImage"
                android:layout_alignLeft="@id/overnightStayImage"
                android:padding="5dp"/>

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_toilet"
                android:text="@string/item_toilet"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/toiletImage"
                android:layout_below="@id/overnightStayImage"/>

                            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/toiletImage"
                android:layout_width="fill_parent"/>

            <ImageView 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" 
                android:id="@+id/electricityImage"
                android:layout_below="@id/toiletImage"
                android:layout_alignLeft="@id/toiletImage"
                android:padding="5dp"/>

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_electricity"
                android:text="@string/item_electricity"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/electricityImage"
                android:layout_below="@id/toiletImage"/>                

                        <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/electricityImage"
                android:layout_width="fill_parent"/>

            <ImageView 
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content" 
                android:id="@+id/cranImage"
                android:layout_below="@id/electricityImage"
                android:layout_alignLeft="@id/electricityImage"
                android:padding="5dp"/>

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_cran"
                android:text="@string/item_cran"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/cranImage"
                android:layout_below="@id/electricityImage"/>        

                            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/cranImage"
                android:layout_width="fill_parent"/>                   

            <ImageView 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" 
                android:id="@+id/slipwayImage"
                android:layout_below="@id/cranImage"
                android:layout_alignLeft="@id/cranImage"
                android:padding="5dp"/> 

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_slipway"
                android:text="@string/item_slipway"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/slipwayImage"
                android:layout_below="@id/cranImage"/>  

                        <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/slipwayImage"
                android:layout_width="fill_parent"/>

            <ImageView 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" 
                android:id="@+id/campingImage"
                android:layout_below="@id/slipwayImage"
                android:layout_alignLeft="@id/slipwayImage"
                android:padding="5dp"/> 

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_camping"
                android:text="@string/item_camping"
                android:textSize="14sp"
                android:layout_toLeftOf="@id/campingImage"
                android:layout_below="@id/slipwayImage"/>       

                            <View
                android:layout_height="1dip"
                android:background="#FF909090"
                android:layout_below="@id/campingImage"
                android:layout_width="fill_parent"/>

            <ImageView
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" 
                android:id="@+id/freshWaterImage"
                android:layout_below="@id/campingImage"
                android:layout_alignLeft="@id/campingImage"
                android:padding="5dp"/> 

            <TextView 
                style="@style/CodeFont"
                android:id="@+id/item_freshWater" 
                android:text="@string/item_freshWater"
               android:textSize="14sp"
               android:layout_toLeftOf="@id/freshWaterImage"
                android:layout_below="@id/campingImage"/>  

        </RelativeLayout>   

    </LinearLayout>

</LinearLayout>
</ScrollView>

1 Ответ

4 голосов
/ 13 мая 2011

Разместите свой файл изображения. И это 9-патч PNG или просто стандартный файл изображения? Без дополнительной информации, я думаю, что ваше изображение слишком велико для вашего пространства, и по какой-то причине, когда оно сжимается, оно должно сжиматься в обоих направлениях, и оно создает пустое пространство сверху. Я заметил этот эффект раньше. Если это то, что происходит, то решения будут либо изменить размер файла изображения, чтобы он не уменьшался, либо (и это, вероятно, предпочтительный способ) создать очень маленький 9-патч, который будет расширяться в изображение ты хочешь. Мне трудно сказать, но, похоже, по изображению ваше изображение в любом случае является сплошным цветом, поэтому, если вы пошли по маршруту с 9 патчами, вы могли бы сделать его очень маленьким холстом размером 10 x 10 пикселей или что-то в этом роде. и он будет знать, как расширить его, чтобы заполнить любое необходимое пространство.

Еще один способ узнать, происходит ли это, - запустить приложение на чем-то с большим экраном. Тогда ему не нужно будет сжимать файл изображения и, следовательно, не должно показывать пустое пространство вверху

...