마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 layout_margin 밀림 현상 질문

0 추천

 

이런식으로 맨위에 textview 옆에 버튼을 만들었는데 layout_margin 속성을 주지않으면 꽉차기 때문에 15dp 정도를 주었습니다.

그런데 옆에 세종대학교 게시판 textview 가 옆으로 밀리네요...

어떻게해야 밀리지않고 버튼이 꽉차게 할수있을까요. 아래는 해당부분 xml 소스입니다.

 

<LinearLayout

        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:weightSum="1"
        android:background="#DCDCDC"
        android:layout_weight="0.2">
 
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#DCDCDC"
            android:layout_weight="0.2"></View>
 
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.6"
            android:text="세종대학교 게시판"
            android:textSize="20dp"
            android:background="#DCDCDC"
            android:gravity="center"
            android:textColor="#0049e9"
            android:textStyle="bold" />
 
        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/plus_btn"
            android:layout_margin="15dp"
            android:textSize="15dp"
            android:layout_weight="0.2"/>
 
    </LinearLayout>
 
+ ) 추가로 actionbar 로 말고 이런식으로 해야하기 때문에 이런식으로 하는겁니다.
Hir00 (740 포인트) 님이 2015년 4월 19일 질문

2개의 답변

0 추천
Button 말고 ImageButton으로 바꾸고, src에다 이미지를 넣어보세요. scaleType은 fitCenter가 좋겠네요
쎄미 (162,410 포인트) 님이 2015년 4월 20일 답변
0 추천

릴레이티브로 짜면됩니다.

<RelativeLayout

        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:weightSum="1"
        android:background="#DCDCDC"
        android:layout_weight="0.2">
 
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#DCDCDC"
            android:layout_alignParentLeft="true"
            android:layout_weight="0.2"></View>
 
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.6"
            android:layout_toLeftOf="@+id/button_id"
            android:layout_toRightOf="@+id/view_id"
            android:text="세종대학교 게시판"
            android:textSize="20dp"
            android:background="#DCDCDC"
            android:gravity="center"
            android:textColor="#0049e9"
            android:textStyle="bold" />
 
        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/plus_btn"
            android:layout_margin="15dp"
            android:layout_alignParentRight="true"
            android:textSize="15dp"
            android:layout_weight="0.2"/>
 
    </RelativeLayout>
콜벳 (7,150 포인트) 님이 2015년 4월 20일 답변
...