简体   繁体   中英

android - apply button default style to linear layout

I want to have a button with multiple TextViews - so I figured I should have a linearlayout and put Textviews inside.

I want the linearlayout to look exactly like the button, and I can't achieve that.

Here is how the button "Add Ride" looks like (not the blue title, the grey button):

在此处输入图片说明

and the button code is like this, without any style:

 <Button
     android:id="@+id/btnAddRide"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_marginTop="10dip"
     android:text="Add Ride" />

How do I make the linearlayout look like this??

thanks!

This is probably the default look of the button. So, if you want your linearlayout too have a look like this then I guess, you will have to take the color of button and have that as background of linearlayout something like

<LinearLayout
    android:id="@+id/lin_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/<btn_bg_color>"
    android:orientation="vertical"
/>

我认为您应该为线性布局添加的内容是:

android:theme="@style/Widget.AppCompat.Button"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM