2016-07-28 3 views
0

이것은 내 .xml 파일이며 모든 화면을 모든 화면에 수평으로 설정하고 싶습니다. 모든 화면 ... 시도했지만 첫째로 내가이 내 .xml 파일을이었다 메뉴가있는 꼬리말을 설정하고 화면마다 동일하게 나누어 진 아이콘을 설정하고 싶습니다.

<ImageView 
     android:id="@+id/imageViewFooter2" 
     android:layout_width="60dp" 
     android:layout_weight="1" 
     android:layout_height="60dp" 
     android:layout_marginLeft="100dp" 
     android:background="@drawable/ic_launcher" 
     android:layout_alignParentBottom="true" 
     /> 

    <ImageView 
     android:id="@+id/imageViewFooter3" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_weight="1" 
     android:background="@drawable/att" 
     android:layout_marginLeft="150dp" 
     android:layout_alignParentBottom="true" 
     /> 

    <ImageView 
     android:id="@+id/imageViewFooter4" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_weight="1" 
     android:scaleType="fitXY" 
     android:layout_marginLeft="250dp" 
     android:background="@drawable/omlogo" 
     android:layout_alignParentBottom="true" 
     /> 
    <View 
     android:layout_width="match_parent" 
     android:layout_height="01dp" 
     android:background="#cec5ce" 
     android:layout_above="@id/imageViewFooter3" 
     android:id="@+id/view"> 

    </View> 
    </RelativeLayout> 

상대 레이아웃 설정 메뉴 모든 이미지 뷰이

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:gravity="center" 
    tools:context="com.example.sachin.attendence.MainActivity"> 

을 위해 도와 .. 일이 아니에요

+0

가중치 만 ** LinearLayouts **에서 작업하십시오. 또는 ** PercentRelativeLayouts **를 대신 사용할 수 있습니다 (이 경우 RelativeLayouts이지만 백분율을 사용할 수 있음). –

답변

1

다른 화면에서 바닥 글을 다시 사용한다고 가정합니다. 이 경우 바닥 글에 다른 XML 파일을 만들어서 포함시켜야합니다.

내가 모든 화면에 footer.xml 파일을 포함하려면이 예

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 
    <size 
     android:width="48dp" 
     android:height="48dp" /> 
    <solid android:color="#757" /> <!-- your background--> 
</shape> 

에서 사용하고 난 간단한 당김 icon을 만들어 footer.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="48dp" 
    android:background="#bbb" 
    android:orientation="horizontal"> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/icon" /> <!-- your image here --> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/icon" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/icon" /> 
</LinearLayout> 

다음과 같은 예를 들어,과 같이 include 태그를 사용합니다 :

<include 
    layout="@layout/footer" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" /> 
관련 문제