对于我的应用程序,我制作了一个屏幕,您可以在其中查看有关商店的信息。这就是我现在所拥有的。(在下图中)我想要填充图像或谷歌地图视图的剩余区域。是否可以通过xml填充剩余区域?或者我该如何解决这个问题?
第二个问题是: 正如你可以在白色区域看到的图标或漂亮的中心。我想将其上方的块上的图标与白色框中图标的左侧对齐。我该怎么做?
代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/winkels_uren_bg"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:paddingLeft="35dp">
<TextView
android:id="@+id/lblStraat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/map"
android:gravity="center_vertical"
android:paddingBottom="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/telefoonnr"
android:drawableLeft="@drawable/telefoon_icon"
android:gravity="center_vertical"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:gravity="center_horizontal">
<LinearLayout
style="@style/winkelinfoicons">
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icobancontact"
android:background="@null"
/>
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icomarkt"
android:background="@null"
/>
</LinearLayout>
<LinearLayout
style="@style/winkelinfoicons">
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icoeducatie"
android:background="@null"
/>
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icomobielestand"
android:background="@null"
/>
</LinearLayout>
<LinearLayout
style="@style/winkelinfoicons">
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icogeschenken"
android:background="@null"
/>
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icovoeding"
android:background="@null"
/>
</LinearLayout>
<LinearLayout
style="@style/winkelinfoicons">
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icoklasbezoek"
android:background="@null"
/>
<ImageButton
style="@style/winkelinfoicon"
android:id="@+id/icowinkel"
android:background="@null"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
实际上我使用include,但我现在粘贴了完整的xml:)。
答案 0 :(得分:0)
如果对齐问题有类似的问题。这就是我修复它的方法。我计算了图标的dp宽度。我把它集中起来。我将上面的textviews的宽度设置为计算值的相同宽度,并将其居中。
答案 1 :(得分:0)
LinearLayout支持为各个孩子分配权重,这将有助于您占用空间。此属性为视图指定“重要性”值,并允许它展开以填充父视图中的任何剩余空间。默认权重为0
计算以分配孩子之间的任何剩余空间
分配给孩子的空间=(儿童个人体重)/(线性布局中每个孩子的体重总和)
示例:如果有三个文本框,其中两个声明权重为1,而第三个没有赋予权重(0),则剩余空间分配给 第1个文本框= 1 /(1 + 1 + 0)第2个文本框= 1 /(1 + 1 + 0)第3个文本框= 0 /(1 + 1 + 0)
试试这个我使用重量占据剩余空间的xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="1dip" android:orientation="horizontal">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight=".7" android:orientation="vertical">
<Button android:id="@+id/header" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/header" android:text="header" />
<TextView android:id="@+id/editText1" android:layout_width="match_parent" android:layout_weight="4" android:layout_height="275dp" android:text="this is the memo/reciept part \r\n this is the memo/reciept part " />
<EditText android:id="@+id/editText2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_span="3" android:padding="18dip" android:text="edit text" android:textColor="#000" android:textSize="18sp" />
<Button android:id="@+id/footer" android:background="@drawable/cashierinputtext" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:textSize="18sp" android:text="footer" android:padding="18dip" android:textColor="#000" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="0.5dip" android:layout_weight="1.9" android:gravity="center_vertical|fill_vertical" android:orientation="vertical">
<Button android:id="@+id/F1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="4dip" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:layout_weight="1" android:text="f1" />
<Button android:id="@+id/F2" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:layout_weight="1" android:text="f2" />
<Button android:id="@+id/F3" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_weight="1" android:background="@drawable/entrykeybutton" android:text="f3" />
<Button android:id="@+id/F4" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:layout_weight="1" android:text="f4" />
<Button android:id="@+id/F5" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_weight="1" android:background="@drawable/entrykeybutton" android:text="f5" />
<Button android:id="@+id/F6" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:text="f6" />
<Button android:id="@+id/F7" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:text="f7" />
<Button android:id="@+id/F8" android:layout_width="wrap_content" android:layout_margin="4dip" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/entrykeybutton" android:text="f8" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>