2013-12-18 21 views
1

時缺少邊界線我有這樣的Android佈局XML:採用了android相對佈局

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="#70a5b3" 
     android:layout_above="@+id/skipIcon"/> 

    <com.m.view.text.MyTextView 
     style="@style/textOnBg" 
     android:layout_toLeftOf="@+id/skipIcon" 
     android:text="Skip" 
     android:textStyle="normal" /> 

    <ImageView 
     android:id="@id/skipIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/signup_skip_icon" /> 
</RelativeLayout> 

,我想創建這樣的佈局

enter image description here

,但我的XML不顯示邊框線。我怎樣才能解決這個問題?

+0

您可以發佈此佈局的您的完整的XML? –

回答

2
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <View 
     android:id="@+id/border_line" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_alignParentTop="true" 
    android:background="#70a5b3" /> 

    <com.m.view.text.MyTextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@+id/skipIcon" 
     android:text="Skip" 
     android:textStyle="normal" /> 

    <ImageView 
     android:id="@id/skipIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_below="@+id/border_line" 
     android:src="@drawable/signup_skip_icon" /> 
</RelativeLayout> 
+0

超級!但爲什麼'android:layout_alignParentTop =「true」'工作並且'android:layout_above =「@ + id/skipIcon」'沒有? –

+0

當我不向'TextView'添加'android:layout_height =「wrap_content」'時會發生什麼? –

+1

TextView總是需要一個高度和寬度參數! {月食會提示錯誤}。我沒有回答你的第一個問題,我曾經有過同樣的問題,並且這對我來說是這樣的! ;-) – AabidMulani

0

嘗試在相對佈局中填充1dp。

+0

沒有幫助。任何其他想法? –

0

試試這個:

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<View 
    android:id="@+id/line" 
    android:layout_width="match_parent" 
    android:layout_height="1dp" 
    android:background="#70a5b3"/> 

<ImageView 
    android:id="@+id/skipIcon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_below="@id/line" 
    android:src="@drawable/signup_skip_icon" /> 

<com.waze.view.text.WazeTextView 
    style="@style/textOnBg" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/line" 
    android:layout_toLeftOf="@id/skipIcon" 
    android:text="Skip" 
    android:textStyle="normal"/> 

</RelativeLayout>