2013-09-09 3 views
0

я установил линейный фон макета, как обычно, с помощьюЛинейный Макет фона не отображается на всех

android:background="@drawable/xxx" 

но это вовсе не отображается как на затмения, а также на устройстве.

Мой файл XML приведен ниже:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:weightSum="10" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="4" 
     android:background="#50595f" 
     android:orientation="vertical" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/title_head" 
      android:padding="15dp" 
      android:text="Setup Wizard" 
      android:textColor="@drawable/wp_text_white" 
      android:textSize="30dp" 
      android:textStyle="bold" 
      android:typeface="normal" /> 

     <ScrollView style="@style/wp_scroll" > 

      <LinearLayout style="@style/wp_1stLinner" > 

       <TextView 
        android:id="@+id/toMakeProcess" 
        style="@style/wp_TextView" 
        android:layout_marginTop="20dp" 
        android:text="@string/toMakeProcess" /> 

       <RelativeLayout style="@style/wp_2stRelative" > 

        <TextView 
         android:id="@+id/bullet1" 
         style="@style/wp_Bullets" 
         android:layout_marginTop="10dp" 
         android:text="@string/bullet_code" /> 

        <TextView 
         android:id="@+id/textOption1" 
         style="@style/wp_TextView" 
         android:layout_marginLeft="5dp" 
         android:layout_marginTop="18dp" 
         android:layout_toRightOf="@+id/bullet1" 
         android:text="@string/option1" /> 

        <TextView 
         android:id="@+id/bullet2" 
         style="@style/wp_Bullets" 
         android:layout_below="@+id/textOption1" 
         android:layout_marginTop="10dp" 
         android:text="@string/bullet_code" /> 

        <TextView 
         android:id="@+id/textOption2" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/textOption1" 
         android:layout_marginLeft="5dp" 
         android:layout_marginTop="18dp" 
         android:layout_toRightOf="@+id/bullet2" 
         android:text="@string/option2" /> 

        <!-- 
         <TextView 
         android:id="@+id/bullet3" 
         style="@style/wp_Bullets" 
         android:layout_below="@+id/textOption2" 
         android:text="@string/bullet_code" /> 




        --> 


        <!-- 
         <TextView 
         android:id="@+id/textOption3" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/textOption2" 
         android:layout_toRightOf="@+id/bullet3" 
         android:text="@string/option3" /> 




        --> 

        <ImageView 
         android:id="@+id/iv_seperator" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/textOption2" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="25dp" 
         android:src="@drawable/separator_924" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_heading" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/iv_seperator" 
         android:layout_marginTop="25dp" 
         android:text="@string/string_setup_wizard_heading" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_1" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_heading" 
         android:layout_marginTop="20dp" 
         android:text="1." /> 

        <ImageView 
         android:id="@+id/iv_setup_wizard_bt" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/tv_setup_wizard_heading" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/tv_setup_wizard_1" 
         android:src="@drawable/icon_bluetooth_active" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_first" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_heading" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/iv_setup_wizard_bt" 
         android:text="@string/string_setup_wizard_first" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_2" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_first" 
         android:layout_marginTop="20dp" 
         android:text="2." /> 

        <ImageView 
         android:id="@+id/iv_setup_wizard_wheel" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/tv_setup_wizard_first" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/tv_setup_wizard_2" 
         android:src="@drawable/icon_wheel_active" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_second" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_first" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/iv_setup_wizard_wheel" 
         android:text="@string/string_setup_wizard_second" /> 

        <!-- 
         <TextView 
         android:id="@+id/tv_setup_wizard_3" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_second" 
         android:layout_marginTop="20dp" 
         android:text="3." /> 

        <ImageView 
         android:id="@+id/iv_setup_wizard_padlock" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/tv_setup_wizard_second" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/tv_setup_wizard_3" 
         android:src="@drawable/icon_padlock_active" /> 

        <TextView 
         android:id="@+id/tv_setup_wizard_third" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/tv_setup_wizard_second" 
         android:layout_marginTop="20dp" 
         android:layout_toRightOf="@+id/iv_setup_wizard_padlock" 
         android:text="@string/string_setup_wizard_third" /> 

        --> 

        <Button 
         android:id="@+id/nextBtn" 
         style="@style/wp_Button" 
         android:layout_below="@+id/tv_setup_wizard_second" 
         android:layout_marginTop="20dp" 
         android:text="@string/string_begin" /> 

        <TextView 
         android:id="@+id/bottam_text" 
         style="@style/wp_TextView" 
         android:layout_below="@+id/nextBtn" 
         android:layout_marginTop="20dp" 
         android:text="@string/bottam_text" /> 
       </RelativeLayout> 
      </LinearLayout> 
     </ScrollView> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/Linear_SetupWizard_Plain" 
     style="@style/wp_1stLinner" 
     android:layout_width="0dp" 
     android:layout_weight="6" 
     android:background="@drawable/shadow_setup" 
     android:visibility="visible" > 

     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/breadcrumbs_greyed" /> 

     <TextView 
      android:id="@+id/TextView_SetupWizard_Plain" 
      style="@style/wp_TextView" 
      android:layout_marginLeft="50dp" 
      android:text="@string/string_setup_wizard_plain" 
      android:textColor="#cfd0d2" 
      android:textSize="36dp" /> 
    </LinearLayout> 
</LinearLayout> 
+0

Вы можете прикрепить свои ресурсы, которые используете – ADT

+0

, shadow.png или shadow.9.png, присутствующие в любой из доступных папок? –

+0

, конечно, файл png присутствует во всех доступных (ldpi, mdpi, hdpi, xhdpi). На самом деле тот же самый файл png отлично выглядит, если он установлен в моем другом проекте как линейный макет. –

ответ

0

Просто угадать, но вы можете быть переопределение background атрибута в @style/wp_1stLinner

Кроме того, вы missining android:layout_height атрибута. Попробуйте что-то вроде android:layout_height="wrap_content"

В любом случае, когда для меня ничего не работает, я стараюсь упростить свой xml; вы можете попробовать оставить только одного ребенка (тот, у которого @drawable/shadow_setup); если появляется фон, затем постепенно добавляйте остальных детей.

+0

Если я удалю стиль, то результат будет таким же, фон не будет отображаться –

+0

Вы можете добавить android: layout_height – ssantos

-1

Изменить

android:layout_width="0dp"

в

android:layout_width="wrap_content"

Это должно решить вашу проблему

+0

Даже если я использую android: layout_width = "wrap_content" и android: layout_height = "wrap_content" или если оба используют fill-parent, то результат тоже такой же –

+0

Знаете что. вы должны научиться предоставлять все необходимые детали для вопроса и научиться ПРИНИМАТЬ ОТВЕТ, из-за вашего плохого рейтинга никто не хочет отвечать на ваш вопрос. –

+0

Прошу прощения, но я уже предоставляю все необходимые детали и, кстати, если нет ответа, как я могу это принять? Может ли ты рассказать мне –

0

Изначально я был LinearLayoutlayout_width="match_parent" и layout_height="wrap_content") внутри ScrollView как го e только два элемента в XML. Я указал android:background="my_color" и он не работал.

Итак, я просто включил весь LinearLayout внутри другого RelativeLayout, чьи layout_width и layout_height были установлены "match_parent".

Это сработало.