2016-12-03 2 views
-2

моя проблема сейчас:Cardview - вид фикс - прикрепить к нижней части [обновлено]

мне нужно «прикрепить» эти две кнопки вниз - я не хочу, чтобы они были доступны для прокручиваться (только на нижней - всегда видимый). Но мой Edittext должен быть прокручиваемый, потому что есть длинный текст. В андроид-студии это выглядит хорошо, но в APP нет.

XML

<android.support.v7.widget.CardView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:cardBackgroundColor="#212121" 
    app:cardCornerRadius="8dp" 
    app:cardElevation="5dp" 
    app:cardMaxElevation="0dp" 
    app:cardPreventCornerOverlap="false" 
    app:cardUseCompatPadding="true"> 

    <EditText 
     android:id="@+id/storyTextView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/choiceButton1" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:background="@null" 
     android:cursorVisible="false" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:lineSpacingMultiplier="1.2" 
     android:paddingBottom="15dp" 
     android:paddingLeft="18dp" 
     android:paddingRight="18dp" 
     android:paddingTop="15dp" 
     android:text="You continue your course to Earth. Two days later, you receive a transmission from HQ saying that they have detected some sort of anomaly on the surface of Mars near an abandoned rover. They ask you to investigate, but ultimately the decision is yours because your mission has already run much longer than planned and supplies are low." 
     android:textColor="#9E9E9E" 
     android:textSize="16sp" 
     /> 

</android.support.v7.widget.CardView> 

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:cardBackgroundColor="#212121" 
    app:cardCornerRadius="8dp" 
    app:cardElevation="5dp" 
    app:cardMaxElevation="0dp" 
    app:cardPreventCornerOverlap="false" 
    app:cardUseCompatPadding="true"> 

    <Button 
     android:id="@+id/choiceButton1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="1dp" 
     android:background="@null" 
     android:text="CONTINUE HOME TO EARTH" 
     android:textColor="#b71c1c"/> 

</android.support.v7.widget.CardView> 

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:cardBackgroundColor="#212121" 
    app:cardCornerRadius="8dp" 
    app:cardElevation="5dp" 
    app:cardMaxElevation="0dp" 
    app:cardPreventCornerOverlap="false" 
    app:cardUseCompatPadding="true"> 


    <Button 
     android:id="@+id/choiceButton2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="1dp" 
     android:background="@null" 
     android:text="STOP AND INVESTIGATE" 
     android:textColor="#b71c1c"/> 

</android.support.v7.widget.CardView> 

Все в:

<LinearLayout 
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:id="@+id/activity_story" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#000000" 
android:orientation="vertical" 
tools:context="com.project.StoryActivity"> 
</LinearLayout> 

IN STUDIO - CLICK

IN APP - CLICK - прокручивать, но это "не приспосабливает"

Я надеюсь, вы понимаете мою проблему, спасибо вы, ребята :)

+0

Что с тобой случилось? – Joy

+0

Что не так с вашей точки зрения? –

+0

Что не так с вашим видом: P –

ответ

0

использование RelativeLayout вместо LinearLayout.

к нижней кнопки,

android:layout_alignParentBottom="true" 

вторая кнопка

android:layout_above="@+id/bottom_button" 

сделать EditText прокруткой,

android:inputType="textMultiLine" 
+0

Удивительный !!! Я должен был сделать несколько cahnges, но это очень помогло мне! спасибо – mousik

0

Прежде всего, вам не нужно использовать cardView для макета, показанного на изображении (используйте относительную компоновку). Чтобы использовать cardView, (screen shot is shown here) Вы должны добавить компиляции «com.android.support:cardview-v7:25.0.1» для build.gradle (Module: приложение) файл cardElevation сделает запас, чтобы получить тень ,

в XML,

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:id="@+id/card_view" 
android:layout_gravity="center" 
android:layout_width="fill_parent" 
android:layout_height="500dp" 
android:layout_margin="5dp" 
card_view:cardBackgroundColor="#212121" 
card_view:cardCornerRadius="2dp" 
card_view:contentPadding="10dp" 
card_view:cardElevation="20dp" 
card_view:cardPreventCornerOverlap="true"> 

    <!--your layout contents ...--> 
    <RelativeLayout 
     android:id="@+id/activity_story" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#212121"> 
     <ImageView 
      android:id="@+id/StoryImageView" 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentTop="true" 
      android:adjustViewBounds="true" 
      android:scaleType="fitXY" 
      android:src="@mipmap/ic_launcher"/> 

     <EditText 
      android:id="@+id/storyTextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/choiceButton1" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_below="@+id/StoryImageView" 
      android:background="@null" 
      android:cursorVisible="false" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:lineSpacingMultiplier="1.2" 
      android:paddingLeft="30dp" 
      android:paddingRight="30dp" 
      android:paddingTop="15dp" 
      android:text="TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       TEXT TEXT TEXT 
       " 
      android:textColor="#9E9E9E" 
      android:textSize="16sp" 
      tools:textColor="#9E9E9E"/> 

     <Button 
      android:id="@+id/choiceButton1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/choiceButton2" 
      android:layout_marginTop="3dp" 
      android:background="#212121" 
      android:text="button1" 
      android:textColor="#b71c1c"/> 

     <Button 
      android:id="@+id/choiceButton2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="11dp" 
      android:layout_marginTop="3dp" 
      android:background="#212121" 
      android:text="button2" 
      android:textColor="#b71c1c"/> 
    </RelativeLayout> 
</android.support.v7.widget.CardView> 
+0

Спасибо, но это не то, что я имел в виду :) Можете ли вы проверить мой обновленный пост? – mousik