2015-04-12 124 views
0

我想在圖像底部添加一個紅色邊框50px高度。如何將邊框添加到圖像底部?

對於前:

enter image description here

 <ImageView android:id="@+id/meme_generated_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_margin="5dp" 
      android:scaleType="fitCenter" /> 


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

      <EditText android:id="@+id/edt_meme_bottom_txt1" android:layout_width="match_parent" 
       android:layout_height="wrap_content" android:layout_margin="5dp" 
       android:background="@drawable/edt_text_bg" android:ems="10" 
       android:hint="Write Text" android:padding="10dp" android:singleLine="true" /> 
     </LinearLayout> 

我從Java文件圖像加載。你能幫我麼。

回答

0

使用下面的代碼,並將其添加下面的圖片

<View android:id="@+id/view" 
      android:layout_width="match_parent" 
      android:layout_height="20dp(as per your requirment)" 
      android:background="your background color or boarder" /> 

UPDATE爲您發佈的代碼通過以下毫升替換您的XML。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation = "vertical"> 

    <ImageView android:id="@+id/meme_generated_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_margin="5dp" 
      android:scaleType="fitCenter" /> 

    <View android:id="@+id/view" 
      android:layout_width="match_parent" 
      android:layout_height="20dp(as per your requirment)" 
      android:background="your background color or boarder" /> 

    </LinearLayout> 


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

      <EditText android:id="@+id/edt_meme_bottom_txt1" android:layout_width="match_parent" 
       android:layout_height="wrap_content" android:layout_margin="5dp" 
       android:background="@drawable/edt_text_bg" android:ems="10" 
       android:hint="Write Text" android:padding="10dp" android:singleLine="true" /> 
     </LinearLayout> 

如果你想加載然後將圖像使視圖的可視性首先去了在圖像視圖完成圖像加載後然後進行通過Java代碼可見視圖後,顯示如下圖的boader。

希望它能幫助你。

+0

我在哪裏可以放這段代碼? imageView的底部? @Sadiq –

+0

@IsmailAltunören將圖像和視圖標籤放置在定向垂直類型的線性佈局中。它將視圖/寄宿在圖像下方 – Sadiq

+0

我更新了我的問題。我的代碼就是這樣。你能解釋一下嗎?我的文本動態獲得從Java文件時,我寫編輯文本 –