2017-02-14 50 views
0

This is my layout。我的問題是,該ID是「below_button」LinearLayout無效,在手機上運行。手機沒有顯示這個LinearLayout,但其他人的佈局是正確的。怎麼來的?爲什麼layout_below在手機上運行無效?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

    <include 
     android:id="@+id/title" 
     layout="@layout/toptitlebar" /> 

    <LinearLayout 
     android:id="@+id/query_detail" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_below="@+id/title" 
     android:background="#e2dfdf" 
     android:layout_alignParentLeft="true"> 
     <EditText 
      android:id="@+id/ram_assistinqnum" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:layout_weight="0.45" 
      android:hint="通知書編號" 
      android:maxLines="1" 
      /> 
     <TextView 
      android:id="@+id/ram_operate_date" 
      style="@style/SpinnerCtl_Wrap" 
      android:gravity="center" 
      android:layout_margin="10dp" 
      android:layout_weight="0.45" 
      android:hint="操作時間" 
      android:textColor="@color/black"/> 
     <ImageView 
      android:id="@+id/ram_query" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="0.1" 
      android:src="@drawable/ram_querry" 
      android:layout_margin="10dp"/> 
    </LinearLayout> 

    <com.sdrcu.operatingdecisions.view.scrollabletbv.ScrollTableView4 
     android:id="@+id/scrollTableView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/query_detail" 
     /> 

    <LinearLayout 
     android:id="@+id/below_button" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:background="#e2dfdf" 
     android:layout_below="@+id/scrollTableView" 
     > 
     <ImageView 
      android:id="@+id/ram_arrow_previous" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleType="center" 
      android:layout_weight="0.3" 
      android:src="@drawable/ram_arrow_previous"/> 
     <TextView 
      android:id="@+id/paging" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.3" 
      android:gravity="center" 
      android:text="翻頁" 
      android:textColor="@color/text_blue" 
      android:textSize="20sp" 
      /> 
     <ImageView 
      android:id="@+id/ram_arrow_next" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleType="center" 
      android:layout_weight="0.3" 
      android:src="@drawable/ram_arrow_next"/> 
     <ImageView 
      android:id="@+id/ram_agree" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.1" 
      android:src="@drawable/ram_agree"/> 
     <ImageView 
      android:id="@+id/ram_disagree" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.1" 
      android:src="@drawable/ram_disagree"/> 

    </LinearLayout> 

</RelativeLayout> 

回答

0

@Seal

在我的佈局編輯器的預覽我改變了「主題編輯器中」,以「主題」
我開始得到錯誤像你的截圖一樣。

參見:

enter image description here


所以,我選擇了 「全部」 - > 「AppTheme」,從 「主題編輯器中的」 選項...不要忘了按 「OK」

enter image description here


而錯誤去的時候

enter image description here

那麼,你爲什麼不也嘗試將其設置爲「所有」 - >「AppTheme」


而且在我看來,你可能已經創建的樣式( s)不從「適當的父母」繼承。

使用例如以下: 「AppTheme」 繼承 「Theme.AppCompat.Light.DarkActionBar」 所有必需的屬性。因此,你只需要指定你需要修改的屬性。

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    ... 

    <item name="colorAccent">@color/colorAccent</item> 

    ... 
</style> 
+0

我沒有錯過這兩個屬性。我用這個樣式引用了SpinnerCtl_Wrap的佈局。 – Seal

+0

@Seal我剛剛在Android設備上添加了這個佈局的「截圖」。你在Android設備上看到了相同的內容嗎? (顯然我已經註釋掉了com.sdrcu.operatingdecisions.view.scrollabletbv.ScrollTableView4,因爲我沒有這個類) –

+0

是的,「ScrollTableView4」是我定義的類。我該怎麼做?對不起,我是一位新的Android開發者!謝謝! – Seal

0

更換

android:layout_below="@id/query_detail" 

<com.sdrcu.operatingdecisions.view.scrollabletbv.ScrollTableView4 
    android:id="@+id/scrollTableView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/query_detail" 
    /> 

android:layout_below="@+id/query_detail" 
0

是你錯過了參數身高和體重

android:layout_width="match_parent" 
android:layout_height="wrap_content" 

添加在佈局它的工作原理Use the Tag

相關問題