2016-10-12 6 views
0

私は、それぞれImageViewTextViewを含む2つのRelativeLayoutsを持っています。 TextViewをクリックすると、TextViewのサイズが大きくなり、もう1つのサイズは小さくなります(Textview)。但し、ImageViewの位置も変わります。textviewのサイズにかかわらずImageを固定したいです。どのような変更を行う必要がありますか?Android - アイコンの位置を固定

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/bb_bottom_bar_outer_container" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:background="@drawable/float_common" 
      android:clickable="true"> 

    <LinearLayout 
     android:id="@+id/btn_updatenow" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/background_grey" 
     android:orientation="horizontal" 
     android:weightSum="3"> 

     <RelativeLayout 
      android:id="@+id/float_layout_home" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:paddingTop="2dp"> 

      <ImageView 
       android:id="@+id/float_image_home" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="@dimen/margin_6" 
       android:background="@drawable/float_home_onclick" 
      /> 

      <TextView 
       android:id="@+id/float_text_home" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_centerHorizontal="true" 
       android:paddingBottom="@dimen/margin_10" 
       android:text="@string/home" 
       android:textColor="@color/text_mid_grey" 
      /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/float_layout_offers" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:orientation="vertical" 
      android:paddingTop="2dp"> 

      <ImageView 
       android:id="@+id/float_offers" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="@dimen/margin_6" 
      /> 

      <TextView 
       android:id="@+id/float_text_offers" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_centerHorizontal="true" 
       android:paddingBottom="@dimen/margin_10" 
       android:text="@string/offers" 
       android:textColor="@color/text_mid_grey" 
      /> 
     </RelativeLayout> 
    </LinearLayout> 

</FrameLayout> 
+1

android:layout_widthを0dpに設定してみてください。 –

+0

@FebiMathew働いてくれてありがとう 論理を説明してください。 – aditya

+0

回答が追加されました。チェックしてください。 –

答えて

2

2 RelativeLayoutのandroid:layout_widthを0dpに設定してみてください。

Linearlayoutには多くのビューが含まれ、layout_weightを1に設定するとlayout_heightまたはlayout_width = 0dpが使用され、両方のビューに等しいスペースを使用します。