2015-06-24 13 views
0

您好我想實現下面的圖片下另一個圖像不顯示的Android

當我去到Android工作室的XML設計這是我想要的東西,但是當我在圈下運行的應用程序的直線未顯示可以在任何身體給我一些提示來解決這個問題? (我也用的FrameLayout而不是RelativeLayout的,但沒有奏效)

編輯:其實我的問題是RelativeLayout的包含直線沒有高度等RelativeLayout的。有誰知道如何解決這個問題?!

編輯2:我將parentLayout更改爲LinearLayout,它的工作原理!我不知道爲什麼,但它的工作!

下面是一些改變後,我的名單中排:

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

    <RelativeLayout 
     android:layout_width="@dimen/circle_area_radius" 
     android:layout_height="match_parent"> 

     <ImageView 
      android:layout_width="3dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="@dimen/half_circle_area_radius" 
      android:background="@color/orange" /> 

     <ImageView 
      android:id="@+id/circle" 
      android:layout_width="@dimen/circle_area_radius" 
      android:layout_height="@dimen/circle_area_radius" 
      android:src="@drawable/circle" /> 


     <com.mycompany.ui.customui.PersianTextView 
      android:id="@+id/araNumber" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_gravity="center" 
      android:layout_marginTop="22dp" 
      android:text="1299" 
      android:textColor="@color/abc_secondary_text_material_dark" 
      android:textSize="12sp" /> 

    </RelativeLayout> 


    <!-- our content --> 
    <LinearLayout 
     android:id="@+id/relativeLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginRight="@dimen/pager_margin" 
     android:layout_marginTop="@dimen/global_padding_large" 
     android:background="@drawable/balloon_incoming_normal" 
     android:orientation="vertical"> 

     <com.mycompany.ui.customui.PersianTextView 
      android:id="@+id/itemText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:layout_marginLeft="@dimen/global_padding_large" 
      android:layout_marginRight="@dimen/global_padding" 
      android:layout_marginTop="@dimen/global_padding" 
      android:ellipsize="end" 
      android:gravity="right" 
      android:textColor="@color/dark_gray" 
      android:textSize="@dimen/textsize_medium" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_marginLeft="@dimen/global_padding_large" 
      android:layout_marginRight="@dimen/global_padding_large" 
      android:layout_marginTop="@dimen/global_padding" 
      android:background="@color/gray_20" /> 

     <com.mycompany.ui.customui.IconTextView 
      android:id="@+id/favoriteButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:padding="@dimen/global_padding" 
      android:layout_marginRight="@dimen/global_padding" 
      android:text="@string/icon_star_empty" 
      android:textColor="@color/black_light" 
      android:textSize="@dimen/textsize_smaller" /> 

    </LinearLayout> 

</LinearLayout> 

enter image description here

enter image description here

+1

你的橙色盒子好像覆蓋了輸出的整個寬度嗎?請提供錯誤的屏幕截圖。 – Mayank

+0

@Mayank感謝您的回覆,我添加的屏幕截圖 – Amir

+0

@Mayank如果我設置layout_height與XXX出現的直線,但是當我將它設置爲match_parent或FILL_PARENT其未顯示其圓下 – Amir

回答

1

的事情是線實際上可能形成,但你不能看到它,因爲它是在圈子後面。如果我是對的,請將其添加到圓圈android:alpha="20"中進行測試。這條線可以在圓圈後面看到。如果有效,下面的解決方案應該可行。

  1. 將fill_parent更改爲match_parent,不推薦使用fill_parent。

由於您在第一個佈局中使用了match_parent。

的解決方案可以是這樣

更好

實施將使用這樣的:

| Circle(V1) | TextView with information(V2) | 

對齊V1到左和頂部(具有圓和直線作爲佈局的中心)。 將V2對齊到V1的右側。

編輯

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


     <!-- this is my straight line --> 
     <ImageView 
      android:layout_width="3dp" 
      android:layout_height="match_parent" 
      android:layout_marginEnd="-65dp" 
      android:layout_marginLeft="31dp" 
      android:src="#f6802e" /> 

你行的高度匹配家長的高度,改變

android:layout_height="fill_parent"> 

android:layout_height="match_parent"> 

EDIT#2

<?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" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:background="#00aaaaaa" 
     android:paddingLeft="65sp" 
     android:src="@drawable/ic_launcher" /> 

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



     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="3sp" 
      android:layout_height="match_parent" 
      android:layout_centerHorizontal="true" 
      android:background="#aa00aa" 
      android:paddingLeft="65sp" 
      android:src="@drawable/ic_launcher" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="65sp" 
      android:layout_height="65sp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:background="#aaaaaa" 
      android:paddingLeft="65sp" 
      android:layout_marginTop="65sp" 
      android:src="@drawable/ic_launcher" /> 

    </RelativeLayout> 

</RelativeLayout> 

上面的代碼運行,並給你所需的輸出,以及,只需更換imageViews(另外,在第一RelativeLayout的是不必要的,充氣他們需要存儲器)。 Here's the screenshot

+0

我的問題是不可見的直線是可見的,但它在圓下,所以我不能看到它。線的高度與我的圈子相同!問題是二RelativeLayout的高度是不一樣 – Amir

+1

你與match_parent – Mayank

+0

是但沒有修復:( – Amir

1

試試這個。

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


      <!-- this is my straight line --> 
      <ImageView 
       android:layout_width="3dp" 
       android:layout_height="match_parent" 
       android:layout_marginEnd="-65dp" 
       android:layout_marginLeft="31dp" 
       android:src="#f6802e" /> 

      <ImageView 
       android:id="@+id/circle" 
       android:layout_width="65dp" 
       android:layout_height="match_parent" 
       android:layout_marginEnd="-65dp" 
       android:layout_marginRight="-65dp" 
       android:src="@drawable/circle" /> 
相關問題