2011-05-10 87 views
0

我有這樣的自定義類...Android版:全屏幕的RelativeLayout

public class DrawView extends ImageView 

當我設置DrawView構造
內的setImageBitmap(bitmap)EditText結束了ImageViewImageView背後充滿屏幕。
我應該如何改變我的佈局來放置EditTextImageView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
> 
<com.hasse.move.DrawView 
    android:id="@+id/mainView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
/> 
<EditText android:id="@+id/addtext" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_below="@+id/mainView" 
    android:text="aaa" 
/> 
</RelativeLayout> 

回答

1

你可以在RelativeLayout中相對於另一個子視圖對齊頂部,底部,左側,右側的視圖,並使用

機器人:layout_above = 「@ + ID/addtext」

入住屬性視圖所有佈局選項。

您是否在您的構造函數中傳遞了屬性集?像這樣:

public DrawView(Context context, AttributeSet set) { 
     super(context, set); 
+0

正如你可以看到我使用android:layout_below =「@ + id/mainView」。 但仍然我的自定義ImageView類是全屏。 – Erik 2011-05-10 14:47:53

+0

是的我的構造函數有(上下文上下文,AttributeSet集) – Erik 2011-05-10 14:48:56

+0

兩天前,我有與RelativeLayout類似的問題。我首先刪除每個視圖的所有屬性,然後再仔細地設置它們,然後它的工作,不能解釋爲什麼,但它的工作到最後... – Lumis 2011-05-10 14:50:47

0

你應該看看Android的:在ImageView的scaleType屬性:d

希望它可以幫助 JQcorreia

+0

我做了,fitXY,fitCenter和centerInside。我仍然有全屏的imageview。爲什麼Imageview沒有響應android:layout_below =「@ + id/mainView」。我花了整天搜索測試來解決這個問題,但沒有運氣 – Erik 2011-05-10 14:11:22