半分

2017-06-26 10 views
1
_________________ 
|  test  | 
|  ______  | 
|_____|  |____| 
     |______| 

は、これは私が...大きな箱が描画可能に作られており、それがのEditTextを持っているの内側に何をしたいです。小さい方のボックスはアップロードのアイコン付きのイメージビューにする必要があります。半分

アイコンは、私は大きなbox.Theのbiggerboxの幅を大きくする必要が表示されても、ストロークを持ってい

_________________ 
|     | 
|_________________| 

ので、ImageViewのが消えてしまいますのEditText(見えない)には何も存在しない場合。

は、これまでのところ、私はこれは私がimagewiewの半分はbiggerboxの内側になりたいので、基本的に私の描画可能

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid 
     android:color="#ff7c00" /> 
    <stroke 
     android:width="1dp" 
     android:color="@color/white"/> 
    <corners 
     android:topLeftRadius="5dp" 
     android:topRightRadius="5dp" 
     android:bottomLeftRadius="5dp" 
     android:bottomRightRadius="5dp"/> 
</shape> 

あるこの

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 
    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingStart="27dp" 
     android:paddingEnd="27dp" 
     android:paddingBottom="10dp" 
     android:paddingTop="10dp" 
     android:alpha=".5" 
     android:background="@drawable/commenting_drawable"> 
     <EditText 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:hint="say something" 
      android:id="@+id/comments_editText" 
      android:textColor="@color/white" 
      android:textColorHint="@color/white_75" 
      android:fontFamily="sans-serif" 
      android:textSize="13sp" 
      android:textCursorDrawable="@null" 
      android:background="@color/transparent" 
      android:layout_centerInParent="true"/> 
    </RelativeLayout> 
    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginTop="35dp"> 
     <ImageView 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:background="@drawable/icn_uploadcomment" 
      android:src="@drawable/black_circle_25"/> 
    </RelativeLayout> 
</FrameLayout> 

のようにそれを作ったと私は大きな箱を作りたいですイメージビューが表示されたときに調整します。

+1

使用中の小さな箱に-veマージンを提供することにより、上記の問題に対する解決策を見つけることができたでframeLayout –

答えて

0

私は、XML

<EditText 
    android:id="@+id/comment_text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="@style/text_comment_style" 
    android:paddingBottom="32dp" /> 
    <ImageView 
    android:id="@+id/comment_recorder_button" 
    android:layout_width="@dimen/progress_comment_recorder_diameter" 
    android:layout_height="@dimen/progress_comment_recorder_diameter" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="-20dp" 
    android:layout_below="@+id/comment_text"/> 
+0

コードを表示するのではなく、問題を修正した理由や方法に何かを追加できますか?これにより、他者はあなたの答えから学び、同様の質問のより広い範囲にそれを適用することができます。 – yanman1234

1

イメージの相対レイアウトの上マージンのサイズを減らして、イメージが重なるようにすることができます。あなたはおそらくすでにあなたがイメージ図を可視と不可視作っているので、レイアウトを操作するためのコードを持っているので、次のように、大きな箱のサイズを変更する最も簡単な方法(IMO)は、パディングを調整するために、次のようになります。

RelativeLayout layout = (RelativeLayout) findViewById(R.id.biggerBox); 
    layout.setPadding(left, top, right, bottom); 

left, top, right, bottomは、大きなボックスのサイズを変更するために必要なパディングです。 (あなたはまた、より大きなボックスにIDを与える必要があります。)

+0

私は上記のレイアウトを-ve marginで行うことができました。私は答えを投稿します。 –

関連する問題