Android 按钮大小取决于背景图像
我正在开发一个应用程序,其中有许多按钮,我想做的是使按钮的大小根据背景图像Android 按钮大小取决于背景图像,android,css,android-layout,android-activity,Android,Css,Android Layout,Android Activity,我正在开发一个应用程序,其中有许多按钮,我想做的是使按钮的大小根据背景图像 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:backgr
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bac"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ttttest.MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:padding="4dip"
android:text="Button" />
[![在此处输入图像描述][1][1]
image=>真的很有趣。从来没有想过这种设计。我想出了一个很接近你想要的东西,我相信。我认为完美地与背景图像对齐是不可能的
<?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:background="@color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>
抱歉,所需信息很少,因此您希望图像的大小与整个背景图像、全屏图像或图像中的单个单元格相同?我希望按钮大小与背景图像中的块大小一致谢谢!祝你申请顺利。