开发者

ScrollView hide button in relative layout

I have 3 components to show in my app: Inside a layout with a background I want to set: TextView + ScrollView + Button at the bottom

This is the code I have done so far:

<RelativeLayout style="@style/fill_parent" android:background="@layout/shapetablehome" android:layout_margin="10dp"
android:layout_alignLeft="@+id/imageUser" android:layout_below="@+id/userblock">
    <LinearLayout style="@style/fill_parent" android:orientation="vertical" android:id="@+id/boxcomment">
        <TextView android:id="@+id/textTime" android:textSize= "18dip" android:textStyle="bold" android:textColor="@color/black"            
            style="@style/wrap_content" android:text="Comento sobre Alicante" android:paddingLeft="10dp"
            android:paddingTop="10dp">
        </TextView>
        <ScrollView style="@style/fill_parent">
            <TextView android:id="@+id/textTime" android:textSize= "18dip" android:textColor="@color/black"
                style="@style/wrap_content" android:text="Comentario sobre Alicante Comentario sobre Alicante
                Comentario sobre AlicanteComentario sobre AlicanteComentario sobre AlicanteComentario sobre Alicante
                Comentario sobre AlicanteComentario sobre AlicanteComentario sobre AlicanteComentario sobre Alicante
                Comentario sobre AlicanteComentario sobre AlicanteComentario sobre AlicanteComentario sobre Alicante
                Comentario sobre AlicanteComentario sobre AlicanteComentario sobre AlicanteComentario sobre Alicante
                Comentario sobre AlicanteComentario sobre AlicanteComentario sobre AlicanteComentario sobre Alicante" 
    开发者_StackOverflow社区            android:paddingLeft="10dp"
                android:layout_below="@+id/textTime" android:paddingTop="10dp">
            </TextView>
        </ScrollView>
    </LinearLayout>
<Button android:id="@+id/btRegister" style="@style/wrap_content" android:gravity="center" 
    android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp"
    android:paddingLeft="10dp" android:paddingRight="10dp" 
    android:background="@layout/selectoryellowbutton" android:textSize="20px" android:layout_height="42dip" 
    android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="Escribir a Inma Bermejo">
</Button>
</RelativeLayout>

The problem is when the comment is too long the text on the ScrollView position behind the button. If I set the button to be below the linerLayout with the textView+ ScrollView, like:

<Button android:id="@+id/btRegister" style="@style/wrap_content" android:gravity="center" 
    android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp"
    android:paddingLeft="10dp" android:paddingRight="10dp" android:layout_below="@+id/boxcomment"
    android:background="@layout/selectoryellowbutton" android:textSize="20px" android:layout_height="42dip" 
    android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="Escribir a Inma Bermejo">
</Button>

The button doesnt appear. I could have used a LinerLayout with the 3 components, but I want the button to position always at the bottom of the layout.

Any suggestion?

Thanks


You shouldn't use value fill_parent as a height of the boxcomment view if you want something to be below this view. Use layout_height="0dip" and layout_weight="1" for this LinearLayout.


add android:layout_below="@+id/boxcomment" to your Button and give a try again.


I have solved the problem using the parameter android:layout_above="@+id/btRegister" for the LinearLayout. Is analog to use the solution I mention before, of using the parameter android:layout_below="@+id/boxcomment" for the button... But for some reason I dont understand the button is hidden whereas using the first it does not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜