Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何管理android中按钮之间的空格_Android_Android Layout_Android Xml_Android Gui - Fatal编程技术网

如何管理android中按钮之间的空格

如何管理android中按钮之间的空格,android,android-layout,android-xml,android-gui,Android,Android Layout,Android Xml,Android Gui,我正在尝试在安卓系统中制作一个带圆圈按钮的拨号板。就像在IOS 7中一样。这是一个链接,您可以在IOS 7中看到拨号板 http://www.google.com.pk/search?q=ios7+dial+pad&biw=1277&bih=524&source=lnms&tbm=isch&sa=X&ei=623sVOfCC4zraOfhgYAK&ved=0CAYQ_AUoAQ#imgdii=_&imgrc=dYMGMoj954Ed

我正在尝试在安卓系统中制作一个带圆圈按钮的拨号板。就像在IOS 7中一样。这是一个链接,您可以在IOS 7中看到拨号板

http://www.google.com.pk/search?q=ios7+dial+pad&biw=1277&bih=524&source=lnms&tbm=isch&sa=X&ei=623sVOfCC4zraOfhgYAK&ved=0CAYQ_AUoAQ#imgdii=_&imgrc=dYMGMoj954EdzM%253A%3B4hEenGnCMC6kYM%3Bhttp%253A%252F%252Fwww.tekshanghai.com%252Fwp-content%252Fuploads%252F2013%252F06%252Fdial-pad.png%3Bhttp%253A%252F%252Fwww.tekshanghai.com%252Fpromotion-free-update-to-ios-7%252F%3B640%3B1136   
布局是完整的,但我面临的问题是手机屏幕大小不同。当我在其他手机上运行我的应用程序时,按钮之间的空间会扩大,或者说空间会增加。我还使用了安卓:layout_weight自动调整按钮的屏幕大小,但它改变了按钮的形状。圆形按钮将其形状变成椭圆形。帮我解决这个问题。 这是布局

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dialpad"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#fcfbdf"
    android:gravity="left" >

    <TableLayout
      android:id="@+id/tableLayout1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/textView11"  
      android:background="#fcfbdf" >

        <TableRow
           android:id="@+id/dial_input_Row"
           android:layout_width="fill_parent"
           android:layout_height="0dp"
           android:layout_marginTop="1dp"
           android:layout_weight="1" >
 <EditText
           android:id="@+id/dial_input_edit_text" 
           android:layout_width="1dp"
           android:layout_height="55dp"
           android:layout_gravity="left"
           android:layout_weight="1"
           android:ems="11"
           android:paddingLeft="5dp" 
           android:paddingRight="5dp"   
           android:textStyle="normal" 
           android:textSize="25dp"                    
           android:inputType="text" 
           android:background="@drawable/subtitle1" 
           android:textColor="#556854">
</TableRow>
 </TableLayout>

<LinearLayout
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:layout_below="@+id/tableLayout1"
                android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="0dp" 
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical" >


    <LinearLayout
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:orientation="vertical" >


        <Button
            android:id="@+id/button1" 
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:background="@drawable/selectorcircle"
            android:paddingBottom="15dp"
            android:text="1"
            android:textColor="@drawable/text_selector"
            android:textSize="13dp"
            android:textStyle="bold"
             />

        <Button
            android:id="@+id/button4"
            android:layout_width="71dp"
            android:layout_height="70dp"

            android:background="@drawable/selectorcircle"
            android:textColor="@drawable/text_selector"
            android:textStyle="bold"
            android:text="4\nGHI" 
            android:textSize="13dp" />

        <Button
                android:id="@+id/button7"
                android:layout_width="71dp"
                android:layout_height="70dp"

                android:background="@drawable/selectorcircle"
                android:textColor="@drawable/text_selector"
                android:textStyle="bold"
                android:text="7\nPQRS" 
                android:textSize="13dp" />

        <Button
            android:id="@+id/button10"
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:textColor="@drawable/text_selector"
            android:textStyle="bold"
            android:background="@drawable/selectorcircle"
            android:text="*" 
            android:textSize="18dp" />
        </LinearLayout>
    </LinearLayout>

  <LinearLayout
        android:layout_width="0dp"  android:layout_marginLeft="20dp"
        android:layout_height="fill_parent"  android:layout_gravity="center"
        android:layout_weight="1"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button2" 
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/selectorcircle"
            android:textColor="@drawable/text_selector"
            android:textStyle="bold"
            android:text="2\nABC" 
            android:textSize="13dp" 

          />

        <Button
            android:id="@+id/button5"
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/selectorcircle"
            android:textColor="@drawable/text_selector"
            android:textStyle="bold"
            android:text="5\nJKL" 
            android:textSize="13dp" />

        <Button
            android:id="@+id/button8"
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/selectorcircle"
            android:textColor="@drawable/text_selector"
            android:textStyle="bold"
            android:text="8\nTUV" 
            android:textSize="13dp" />

        <Button
            android:id="@+id/button11"
            android:layout_width="71dp"
            android:layout_height="70dp"
            android:textStyle="bold"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/selectorcircle"
            android:textColor="@drawable/text_selector"
            android:text="0" 
            android:textSize="15dp" />
    </LinearLayout> 
    </LinearLayout>   
   </RelativeLayout>

选择或循环XML

<?xml version="1.0" encoding="utf-8"?>


<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="oval">

  <stroke android:width="2dp" android:color="#eee460" />

  <gradient

        android:startColor="#bcbcbc"
        android:endColor="#afafaf"
        android:angle="360"
     />

</shape>

使用GridLayoutManager()并将其设置为跨越3列

为此,您需要使用RecyclerView

还可以使用GridView()并调整拉伸模式

此外,按钮更改大小的原因是使用布局权重来扩展布局大小,并且由于形状为椭圆形,因此将调用要创建的椭圆形形状。为此,您可以创建自定义视图并覆盖onMeasure以将视图的高度和宽度设置为相等。

尝试此操作

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
    </LinearLayout>

</LinearLayout>


您可以使用按钮代替imageview。

在不更改布局的情况下,给我一些其他解决方案