2015-12-19 2 views
1

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

раскладка активность:

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

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view_mood_detail_activity" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 

</RelativeLayout> 

вид строка зрения ресайклера:

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

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     <LinearLayout 
      android:id="@+id/row_layout" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_large" 
      android:layout_marginRight="@dimen/margin_large" 
      > 

      <ImageView 
       android:id="@+id/quote_image_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="300dp" 
       android:scaleType="centerCrop" 
       /> 
      <include 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       layout="@layout/layout_like_and_share" 
       android:layout_gravity="right" 
       /> 
      <com.ascentbrezie.brezie.custom.CustomTextView 
       android:id="@+id/comments_count_text_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textSize="@dimen/text_size_small" 
       android:layout_margin="@dimen/margin_small" 
       /> 
      <LinearLayout 
       android:id="@+id/display_comments_layout_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" 
       android:layout_margin="@dimen/margin_small" 
       /> 

      <include 
       android:id="@+id/abc" 
       layout="@layout/layout_add_comments" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       /> 

     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 

Когда я использую выше двух кодов у меня есть выход как this

Но я хочу, чтобы установить edittext и кнопку на кнопке макета в качестве нижнего колонтитула, для этого, когда я использую этот макет.

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

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     <LinearLayout 
      android:id="@+id/row_layout" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_large" 
      android:layout_marginRight="@dimen/margin_large" 
      > 

      <ImageView 
       android:id="@+id/quote_image_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="300dp" 
       android:scaleType="centerCrop" 
       /> 
      <include 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       layout="@layout/layout_like_and_share" 
       android:layout_gravity="right" 
       /> 
      <com.ascentbrezie.brezie.custom.CustomTextView 
       android:id="@+id/comments_count_text_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textSize="@dimen/text_size_small" 
       android:layout_margin="@dimen/margin_small" 
       /> 
      <LinearLayout 
       android:id="@+id/display_comments_layout_mood_detail_activity" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" 
       android:layout_margin="@dimen/margin_small" 
       /> 

     </LinearLayout> 
    </ScrollView> 

    <include 
     android:id="@+id/abc" 
     layout="@layout/layout_add_comments" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     /> 

</RelativeLayout> 

Теперь проблема в том, что я получаю предварительный просмотр XML точно так, как я хочу. Посмотрите [здесь], но когда я запускаю приложение на любом устройстве, я получаю вывод, как this.

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

RowLayout - это линейная компоновка внутри прокрутки. Ширина карты ширина экрана

rowLayout = (LinearLayout) holder.v.findViewById(R.id.row_layout); 

FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(cardWidth, ViewGroup.LayoutParams.FILL_PARENT); 
layoutParams.setMargins(10, 10, 0, 0); 
rowLayout.setLayoutParams(layoutParams); 
+0

Почему вы не добавлять поля в самом файле макета? Также попробуйте использовать 'android: layout_weight = 1' и установите' android: layout_width = "0dp" 'для элементов управления, которые вы хотите заполнить родительским. – AndroidMechanic

+0

Установка ширины макета как 0dp и веса, потому что я хочу, чтобы два элемента в макете распределялись по доступному пространству – jigar

ответ

0

Это должно сделать это

<LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"><EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button"/></LinearLayout>

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