2015-01-01 3 views
1

У меня проблема выравнивания в моем приложении. Я хочу создать три раздела. Верхняя сторона - это меню, нижняя сторона - это меню и раздел карты в середине экрана. Но, как вы можете видеть на картинке, я не мог выровнять второе меню в нижней части экранаСтрока таблицы Android выровнена внизу

Вот мой макет XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    tools:context="com.ufukugur.app.MainActivity" 
    android:background="#000"> 
<!-- menu on the top --> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:id="@+id/ustMenu"> 
     <TableRow 
      android:layout_marginLeft="0dp" 
      android:layout_marginTop="0dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="7" > 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="50dp" 
        android:layout_height="50dp" 
        android:clickable="false" 
        android:gravity="left" 
        android:id="@+id/imgLogo"/> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menunokta" 
        android:id="@+id/imgMenuNokta"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuNokta" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="Sembol" 
        android:layout_alignParentBottom="true" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menucizgi" 
        android:id="@+id/imgMenuCizgi"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuCizgi" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="Rota" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menubolge" 
        android:id="@+id/imgMenuBolge"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuBolge" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="Bölge" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menunotam" 
        android:id="@+id/imgMenuNotam"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuNotam" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="Notam" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menufir" 
        android:id="@+id/imgMenuFir"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuFir" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="FIR" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 

      <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="36dp" 
        android:clickable="true" 
        android:onClick="menuHarita" 
        android:gravity="center_horizontal" 
        android:src="@drawable/menutrafik" 
        android:id="@+id/imgMenuTrafik"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/imgMenuTrafik" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:text="Trafik" 
        android:gravity="center_horizontal" 
        android:textColor="#fff" /> 
      </RelativeLayout> 
     </TableRow> 
    </RelativeLayout> 

<!-- map and other things middle of the screen --> 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mapView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="60dp" 
     android:layout_marginBottom="60dp" 
     android:name="com.google.android.gms.maps.MapFragment" 
     android:layout_alignParentBottom="true" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="GPS bağlantısı sağlanıyor..." 
     android:id="@+id/textKonum" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:textColor="#ff0" 
     android:background="@color/black_overlay"/> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="" 
     android:id="@+id/textYakin" 
     android:layout_alignParentBottom="true" 
     android:gravity="center_horizontal" 
     android:background="@color/black_overlay"/> 

    <ImageView 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="50dp" 
     android:clickable="true" 
     android:onClick="notamClicked" 
     android:src="@drawable/unlems" 
     android:id="@+id/imgNotam"/> 

    <ImageView 
     android:layout_width="35dp" 
     android:layout_height="35dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="10dp" 
     android:layout_marginBottom="40dp" 
     android:clickable="false" 
     android:id="@+id/imageGSM"/> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/hats_basla" 
     android:clickable="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="70dp" 
     android:id="@+id/imbKayit" /> 

<!-- bottom menu --> 
    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:weightSum="6" > 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menuharita" 
       android:id="@+id/imgMenuHarita"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuHarita" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Harita" 
       android:layout_alignParentBottom="true" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menuguncel" 
       android:id="@+id/imgMenuGuncel"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuGuncel" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Güncelle" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menubilgi" 
       android:id="@+id/imgMenuBilgi"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuBilgi" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="HATS" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menuayarlar" 
       android:id="@+id/imgMenuAyarlar"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuAyarlar" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Ayarlar" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menuara" 
       android:id="@+id/imgMenuAra"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuAra" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Ara" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 

     <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:onClick="menuHarita" 
       android:gravity="center_horizontal" 
       android:src="@drawable/menuradar" 
       android:id="@+id/imgMenuRadar"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imgMenuRadar" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:text="Meteo" 
       android:gravity="center_horizontal" 
       android:textColor="#fff" /> 
     </RelativeLayout> 
    </TableRow> 
</RelativeLayout> 

enter image description here

+0

Вставьте fragmnet и все другие вещи, которые должны быть посередине в строке таблицы. – Lal

ответ

0

Вы можете попробовать эту модифицированную схему, его полностью отличается от того, что вы создали, но результат тот же, который, вероятно, вы хотите.

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <!-- TOP SIDE MENU AND OTHER VIEWS --> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:contentDescription="@null" 
       android:gravity="center_horizontal" 
       android:onClick="menuHarita" 
       android:src="@drawable/ic_launcher" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center_horizontal" 
       android:layout_gravity="center" 
       android:text="Img1" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000" /> 
     </LinearLayout> 


     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:contentDescription="@null" 
       android:gravity="center_horizontal" 
       android:onClick="menuHarita" 
       android:src="@drawable/ic_launcher" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="Img2" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000" /> 
     </LinearLayout> 

     // ADD YOUR REMAINING VIEWS HERE.......... 

    </LinearLayout> 


    <!-- MIDDLE LAYOUT MAP AND OTHER VIEW --> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <fragment 
      android:id="@+id/mapView" 
      android:name="com.google.android.gms.maps.MapFragment" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 

     <TextView 
      android:id="@+id/firstTextView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="GPS bağlantısı sağlanıyor..." 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentTop="true"/> 

     <TextView 
      android:id="@+id/firstTextView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="GPS bağlantısı sağlanıyor..." 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentBottom="true"/> 

     // ADD OTHER VIEWS HERE, BE CARE FULL THE PARENT LAYOUT IS RELATIVE LAYOUT 
      SO, ADD REMAINING THREE IMAGE VIEWS ACCORDINGLY...... 

    </RelativeLayout> 


    <!-- LOWER LAYOUT AND OTHER VIEWS VIEWING HORIZONTALLY --> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:contentDescription="@null" 
       android:gravity="center_horizontal" 
       android:onClick="menuHarita" 
       android:src="@drawable/ic_launcher" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="img1" 
       android:layout_gravity="center" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000" /> 
     </LinearLayout> 


     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="36dp" 
       android:clickable="true" 
       android:contentDescription="@null" 
       android:gravity="center_horizontal" 
       android:onClick="menuHarita" 
       android:src="@drawable/ic_launcher" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="img2" 
       android:layout_gravity="center" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#000" /> 
     </LinearLayout> 

     // ADD OTHER VIEW HERE...... 

    </LinearLayout> 



</LinearLayout> 

ПРИМЕЧАНИЕ. Вам необходимо заменить свои идентификаторы и другие ресурсы. Просто чтобы проверить, работает ли этот макет согласно вашему требованию, просто скопируйте и вставьте мой макет и проверьте. И внесите изменения согласно вашим требованиям.

+0

Сообщите мне, работает ли это для вашего или нет .... –

+0

Спасибо. Он работал с небольшой модификацией. Я добавил tablerow для up и bottom linearlayout. Потому что мне нужно использовать экран полной ширины. –

+0

Ваш прием, Ufuk Ugur ... –

 Смежные вопросы

  • Нет связанных вопросов^_^