2015-08-28 5 views
-1

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

<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]

изображения =>https://goo.gl/A1alDZ

+0

К сожалению мало информации требуется, так что вы хотите, чтобы изображение было размером всего фонового изображения, полный экран по существу или только отдельные клетки в изображении? –

+0

Я хочу размер кнопки в соответствии с блоками в фоновом режиме –

ответ

1

Интересных действительно. Никогда не думал о таком дизайне. Ну, я придумал кое-что, что очень близко к тому, что вы ищете, я верю. Не верю, что выравнивание к фоновому изображению невозможно.

<?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> 

+0

вы потрясающий !!! –

+0

Спасибо! Удачи вам в вашей заявке. –

+0

большое вам спасибо. –

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