2015-05-07 2 views
-2

Я хочу создать следующий макет.LinearLayout не работает с RelativeLayout

-------------------------------- 



Title 
Summary     Info 

[Get Direction][Call][More Info] 
-------------------------------- 

Я кодирую следующую схему, но кнопки не отображаются. Я понятия не имею, почему LinearLayout работает как FrameLayout, поэтому RelativeLayout скрывает кнопки. Я что-то пропустил? Я использую поддержки библиотеки 22,1

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/location_card_height"> 

    <ImageView android:id="@+id/cardImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="center" 
     android:layout_gravity="center" /> 

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

     <RelativeLayout 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="bottom" > 

      <TextView android:id="@+id/title" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLargeInverse" 
       android:singleLine="true" 
       android:hint="Title" /> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 

       android:layout_alignParentRight="true" 
       android:layout_below="@id/title"> 

       <TextView android:id="@+id/info" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:textAppearance="?android:attr/textAppearance" 
        android:singleLine="true" 
        android:hint="Info" 

        android:layout_alignParentRight="true" 
        android:ellipsize="end" /> 

       <TextView android:id="@+id/summary" 
        android:layout_height="wrap_content" 
        android:layout_width="match_parent" 
        android:textAppearance="?android:attr/textAppearance" 
        android:singleLine="true" 
        android:hint="Summary" 

        android:layout_toLeftOf="@id/info" 
        android:ellipsize="end" /> 
      </RelativeLayout> 

     </RelativeLayout> 

     <LinearLayout 
      android:id="@+id/panelAction" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <Button 
       android:id="@+id/btnDirection" 
       android:text="@string/get_direction" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Button 
       android:id="@+id/btnCall" 
       android:text="@string/label_call" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Button 
       android:id="@+id/btnMoreInfo" 
       android:text="@string/more_info" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </LinearLayout> 

</FrameLayout> 
+0

Вы хотите только над Layout? Или вы хотите сделать это только в FrameLayout? –

ответ

0

Ваш родственник макет был установлен в match_parent для него высоты!

изменить его wrap_content , которые должны помочь вам

или положить его в LinearLayout что-то вроде этого:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/location_card_height"> 

    <ImageView android:id="@+id/cardImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="center" 
     android:layout_gravity="center" /> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="5" 
      android:orientation="vertical" > 

      <RelativeLayout 
       android:paddingLeft="16dp" 
       android:paddingRight="16dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="bottom" > 

       <TextView android:id="@+id/title" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLargeInverse" 
        android:singleLine="true" 
        android:hint="Title" /> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 

        android:layout_alignParentRight="true" 
        android:layout_below="@id/title"> 

        <TextView android:id="@+id/info" 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:textAppearance="?android:attr/textAppearance" 
         android:singleLine="true" 
         android:hint="Info" 

         android:layout_alignParentRight="true" 
         android:ellipsize="end" /> 

        <TextView android:id="@+id/summary" 
         android:layout_height="wrap_content" 
         android:layout_width="match_parent" 
         android:textAppearance="?android:attr/textAppearance" 
         android:singleLine="true" 
         android:hint="Summary" 

         android:layout_toLeftOf="@id/info" 
         android:ellipsize="end" /> 
       </RelativeLayout> 

      </RelativeLayout> 
     </LinearLayout> 


     <LinearLayout 
      android:id="@+id/panelAction" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      > 

      <Button 
       android:id="@+id/btnDirection" 
       android:text="@string/get_direction" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Button 
       android:id="@+id/btnCall" 
       android:text="@string/label_call" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <Button 
       android:id="@+id/btnMoreInfo" 
       android:text="@string/more_info" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </LinearLayout> 

</FrameLayout> 
+0

Спасибо, я был таким глупым – Chk0nDanger

0

Если вы прекрасны с LinearLayout Тогда Здесь Ваш файл 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="match_parent" 
android:orientation="vertical" 
android:weightSum="1" > 

<ImageView 
    android:id="@+id/cardImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:scaleType="center" 
    android:src="@drawable/ic_launcher" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Title" 
     android:singleLine="true" 
     android:text="Title" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/summary" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_toLeftOf="@id/info" 
      android:layout_weight="1" 
      android:ellipsize="end" 
      android:hint="Summary" 
      android:singleLine="true" 
      android:text="Summary" 
      android:textAppearance="?android:attr/textAppearance" /> 

     <TextView 
      android:id="@+id/info" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_weight="1" 
      android:ellipsize="end" 
      android:gravity="right" 
      android:hint="Info" 
      android:singleLine="true" 
      android:text="Info" 
      android:textAppearance="?android:attr/textAppearance" /> 
    </TableRow> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/panelAction" 
    android:layout_width="match_parent" 
    android:layout_height="40dp" 
    android:gravity="bottom" > 

    <Button 
     android:id="@+id/btnDirection" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Get_direction" /> 

    <Button 
     android:id="@+id/btnCall" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="call" /> 

    <Button 
     android:id="@+id/btnMoreInfo" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="more_info" /> 
</LinearLayout> 

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