Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.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 - Fatal编程技术网

Android布局为图片创建两行一列组合

Android布局为图片创建两行一列组合,android,android-layout,Android,Android Layout,我正在尝试创建一个这样的布局。首先,GridLayout是解决这个问题的最佳方法吗?我尝试了许多不同的布局,但每个都有自己的问题。下面是我试过的代码。感谢您的帮助。提前谢谢 <?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

我正在尝试创建一个这样的布局。首先,
GridLayout
是解决这个问题的最佳方法吗?我尝试了许多不同的布局,但每个都有自己的问题。下面是我试过的代码。感谢您的帮助。提前谢谢

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"    
    android:rowCount="2"
    android:columnCount="3">

            <ImageButton
        android:src="@drawable/avatar_male_update"
        android:scaleType="fitCenter"
        android:adjustViewBounds="true"
        android:layout_height="100dp"
        android:layout_width="100dp"
        android:layout_row="0"
        android:layout_column="0"
        android:id="@+id/imageButtonMale" />

                <Button
        android:text="Refresh"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mybutton"

        android:layout_row="0"
        android:layout_column="1" 
        android:id="@+id/btnCSRefresh" />

                <Button
        android:text="Change Avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/mybutton"
        android:layout_row="0"
        android:layout_column="2"
        android:id="@+id/btnChangeAvatar" />

            <LinearLayout
    android:orientation="vertical"
                android:layout_row="1"
        android:layout_column="0"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="50dp"

    android:id="@+id/linearLayoutButtons">

         <TextView
    android:text="Welcome "
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:id="@+id/txtViewHeader"
    android:background="#FE6A00" />
<ListView
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:id="@+id/lstViewSummary" />

    </LinearLayout>



我不太清楚您真正想要什么,因为您在xml中使用的是listview,所以请更清楚地发布您的问题

为您的布局尝试以下方法:


我不太清楚您真正想要的是什么,因为您在xml中使用的是listview,所以请更清楚地发布您的问题

为您的布局尝试以下方法:


我不太清楚您真正想要的是什么,因为您在xml中使用的是listview,所以请更清楚地发布您的问题

为您的布局尝试以下方法:


我不太清楚您真正想要的是什么,因为您在xml中使用的是listview,所以请更清楚地发布您的问题

为您的布局尝试以下方法:


我应该否决你的问题,因为你的xml与你的图片不匹配

但是如果你想要你在照片上画的东西:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ImageView 
    android:align_parentLeft="true"
    android:center_in_vertical="true"
    android:id="@+id/imageButtonMale"
    android:layout_height="100dp"
    android:layout_width="100dp" />

    <View 
      android:id="@+id/spacer1"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:align_toRightOf="@id/imageButtonMale"
      android:center_vertical="true" />

    <Button
      android:text="Refresh"
      android:id="@+id/btnCSRefresh"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Change Avatar"
      android:id="@+id/btnChangeAvatar"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/btnCSRefresh"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

    <Button
      android:text="Row2Col1"
      android:id="@+id/button_below_refresh_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Row2Col2"
      android:id="@+id/button_below_change_avatar_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/button_below_in_col1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
</RelativeLayout>

有几点:


这将环绕,这意味着如果您想将其扩展到屏幕宽度,您可以将相对布局父宽度更改为
match\u parent
。现在,根据您是否希望按钮的宽度相等,您可以将其宽度更改为
match_parent
,但必须将
android:align_parentRight
更改为第2列中的两个按钮,并将
android:align_toLeftOf=“@id/button_in_col2”
添加到第一列中的按钮(也就是说,第1列中的按钮位于imageview的右侧,第2列中的按钮位于右侧;第1列中的按钮与其右侧的父按钮对齐;两个按钮将占用相同的空间,以上述对齐方式匹配父按钮)。

我应该否决您的问题,因为您的xml与图片不匹配

但是如果你想要你在照片上画的东西:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ImageView 
    android:align_parentLeft="true"
    android:center_in_vertical="true"
    android:id="@+id/imageButtonMale"
    android:layout_height="100dp"
    android:layout_width="100dp" />

    <View 
      android:id="@+id/spacer1"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:align_toRightOf="@id/imageButtonMale"
      android:center_vertical="true" />

    <Button
      android:text="Refresh"
      android:id="@+id/btnCSRefresh"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Change Avatar"
      android:id="@+id/btnChangeAvatar"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/btnCSRefresh"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

    <Button
      android:text="Row2Col1"
      android:id="@+id/button_below_refresh_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Row2Col2"
      android:id="@+id/button_below_change_avatar_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/button_below_in_col1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
</RelativeLayout>

有几点:


这将环绕,这意味着如果您想将其扩展到屏幕宽度,您可以将相对布局父级宽度更改为
match\u parent
。现在,根据您是否希望按钮具有相同的宽度,您可以将其宽度更改为
match\u parent
,但必须将
android:align\u parentRight
更改为bo第2列中的按钮,并将android:align_toLeftOf=“@id/button_in_col2”添加到第1列中的按钮(也就是说,第1列中的按钮位于imageview的右侧,第2列中的按钮位于右侧;第1列中的按钮与其右侧的父按钮对齐;两个按钮将占用相同的空间,以上述对齐方式匹配父按钮)。

我应该否决您的问题,因为您的xml与图片不匹配

但是如果你想要你在照片上画的东西:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ImageView 
    android:align_parentLeft="true"
    android:center_in_vertical="true"
    android:id="@+id/imageButtonMale"
    android:layout_height="100dp"
    android:layout_width="100dp" />

    <View 
      android:id="@+id/spacer1"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:align_toRightOf="@id/imageButtonMale"
      android:center_vertical="true" />

    <Button
      android:text="Refresh"
      android:id="@+id/btnCSRefresh"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Change Avatar"
      android:id="@+id/btnChangeAvatar"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/btnCSRefresh"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

    <Button
      android:text="Row2Col1"
      android:id="@+id/button_below_refresh_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Row2Col2"
      android:id="@+id/button_below_change_avatar_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/button_below_in_col1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
</RelativeLayout>

有几点:


这将环绕,这意味着如果您想将其扩展到屏幕宽度,您可以将相对布局父级宽度更改为
match\u parent
。现在,根据您是否希望按钮具有相同的宽度,您可以将其宽度更改为
match\u parent
,但必须将
android:align\u parentRight
更改为bo第2列中的按钮,并将android:align_toLeftOf=“@id/button_in_col2”添加到第1列中的按钮(也就是说,第1列中的按钮位于imageview的右侧,第2列中的按钮位于右侧;第1列中的按钮与其右侧的父按钮对齐;两个按钮将占用相同的空间,以上述对齐方式匹配父按钮)。

我应该否决您的问题,因为您的xml与图片不匹配

但是如果你想要你在照片上画的东西:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ImageView 
    android:align_parentLeft="true"
    android:center_in_vertical="true"
    android:id="@+id/imageButtonMale"
    android:layout_height="100dp"
    android:layout_width="100dp" />

    <View 
      android:id="@+id/spacer1"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:align_toRightOf="@id/imageButtonMale"
      android:center_vertical="true" />

    <Button
      android:text="Refresh"
      android:id="@+id/btnCSRefresh"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Change Avatar"
      android:id="@+id/btnChangeAvatar"
      android:layout_above="@id/spacer1"
      android:align_toRightOf="@id/btnCSRefresh"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

    <Button
      android:text="Row2Col1"
      android:id="@+id/button_below_refresh_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/imageButtonMale"
      android:layout_width="100dp"
      android:layout_height="100dp" />

    <Button
      android:text="Row2Col2"
      android:id="@+id/button_below_change_avatar_button"
      android:layout_below="@id/spacer1"
      android:align_toRightOf="@id/button_below_in_col1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
</RelativeLayout>

有几点:


这将环绕,这意味着如果您想将其扩展到屏幕宽度,您可以将相对布局父级宽度更改为
match\u parent
。现在,根据您是否希望按钮具有相同的宽度,您可以将其宽度更改为
match\u parent
,但必须将
android:align\u parentRight
更改为bo第2列中的按钮,并将android:align_toLeftOf=“@id/button_in_col2”添加到第1列中的按钮(即,第1列中的按钮位于imageview的右侧,第2列中的按钮位于右侧;第1列中的按钮与其右侧的父按钮对齐;与上述对齐方式匹配的两个按钮将占用相等的空间).

谢谢你,先生。它不仅解决了我的问题,我还学到了一些东西。我不能要求更多。为你干杯!谢谢你,先生。它不仅解决了我的问题,而且我也学到了一些东西。我不能要求更多。为你干杯!谢谢你,先生。不仅解决了我的问题,我也学到了一些东西。我不能要求更多。干杯谢谢你!先生。这不仅解决了我的问题,而且我也学到了一些东西。我不能再要求更多了。为你干杯!