1

enter image description here 다음은 content_main.xml 레이아웃 파일 코드입니다. 다음은안드로이드 버튼, 텍스트 및 이미지를 갖는 테이블 레이아웃이있는 상대적 레이아웃

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 

     <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:weightSum="1" 
       android:layout_weight="0.5"> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Area" 
         android:id="@+id/area" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:id="@+id/imageView" /> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Length" 
         android:id="@+id/length" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Weight" 
         android:id="@+id/weight" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
      </TableRow> 

      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:weightSum="1" 
       android:layout_weight="0.5"> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Temperature" 
         android:id="@+id/temperature" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Cooking" 
         android:id="@+id/cooking" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Currency" 
         android:id="@+id/currency" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
      </TableRow> 

      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:weightSum="1" 
       android:layout_weight="0.5"> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Digital Storage" 
         android:id="@+id/storage" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Energy" 
         android:id="@+id/energy" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Fuel Consumption" 
         android:id="@+id/fuel" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
      </TableRow> 

      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:weightSum="1" 
       android:layout_weight="0.5"> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Power" 
         android:id="@+id/power" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Pressure" 
         android:id="@+id/pressure" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Speed" 
         android:id="@+id/speed" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
      </TableRow> 

      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:weightSum="1" 
       android:layout_weight="0.5"> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Time" 
         android:id="@+id/time" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Torque" 
         android:id="@+id/torque" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.33"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:text="Volume" 
         android:id="@+id/volume" 
         android:textSize="12sp" 
         android:onClick="onClick" 
         android:gravity="center|bottom" 
         android:paddingBottom="10dp"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"/> 
       </RelativeLayout> 
      </TableRow> 
     </TableLayout> 

    </RelativeLayout> 

activity_main.xml 파일입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="sg.unitconverter.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_main"/> 

</android.support.design.widget.CoordinatorLayout> 

AREA, 길이와 무게를 갖는 첫 번째 행의 나머지 부분과 다른 이상 내가 디자인의 출력으로 가지고있는 이미지입니다 행. 모든 행의 크기가 동일 해지기를 바랍니다. 아무도 도와 줄 수 있습니까? 이를 상쇄하기 위해 actionBar의 높이와 동일한 내용의 상단에

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="sg.unitconverter"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name="sg.unitconverter.MainActivity" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name="sg.unitconverter.StandardCal" 
      android:label="@string/title_activity_standard_cal" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.ScientificCal" 
      android:label="@string/title_activity_scientific_cal" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitConverter" 
      android:label="@string/title_activity_unit_coverter" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitArea" 
      android:label="@string/title_activity_unit_area" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitLength" 
      android:label="@string/title_activity_unit_length" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitWeight" 
      android:label="@string/title_activity_unit_weight" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitTemperature" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitCooking" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitCurrency" 
      android:label="@string/title_activity_unit_area" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitEnergy" 
      android:label="@string/title_activity_unit_length" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitFuel" 
      android:label="@string/title_activity_unit_weight" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitPower" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitPressure" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitSpeed" 
      android:label="@string/title_activity_unit_area" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitStorage" 
      android:label="@string/title_activity_unit_length" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitTime" 
      android:label="@string/title_activity_unit_weight" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitTorque" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.UnitVolume" 
      android:label="@string/title_activity_unit_temperature" 
      android:theme="@style/AppTheme.NoActionBar" /> 
     <activity 
      android:name="sg.unitconverter.History" 
      android:label="@string/title_activity_history" 
      android:theme="@style/AppTheme.NoActionBar"></activity> 
    </application> 

</manifest> 
+0

왜 유 girdlayout 관리자와 recylerview을 사용하지 말아 https://developer.android.com/guide/topics/ui/layout/recyclerview.html – Pavan

+0

와 나는 현재 유 @Pavan 모두 동일한 크기 항목 – Pavan

+0

있는 것을 볼 수 있습니다, 그것에 대해 많이 알지 못했습니다. 그래서 나는 이것을 시도했다. 동일한 레이아웃을위한 솔루션이 있습니까? – userash

답변

0

추가 패딩 :

또한
<RelativeLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="?attr/actionBarSize" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 
... 

모든 fill_parentmatch_parent로 대체 아래

는 매니페스트 XML 파일입니다 이는 더 이상 사용되지 않으며 둘 다 같은 것을합니다.

+0

고마워요. 이것은 완벽하게 작동했습니다. – userash

0

툴바가 콘텐츠 레이아웃을 중첩한다고 생각합니다. app:layout_behavior="@string/appbar_scrolling_view_behavior"을 루트 RelativeLayout에 추가하기 만하면 안쪽 여백을 사용하지 마십시오.

관련 문제