简体   繁体   English

如何实现这种布局?

[英]How can I achieve this layout?

I am trying to achieve this in an android app layout. 我正在尝试在Android应用程序布局中实现这一目标。 在此处输入图片说明

So far I have managed to get the buttons the way I wish, but I am having trouble working out how I am going to implement the divider and the layout on the right side of it. 到目前为止,我已经设法按期望的方式获得了按钮,但是我在确定如何实现分隔符及其右侧布局方面遇到了麻烦。

Here is what I have so far: 这是我到目前为止的内容:

<?xml version="1.0" encoding="utf-8"?>
<!-- this is main activity's layout. a main menu of sorts. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center" android:background="@drawable/background">
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/layout_maintest2_relativelayoutleft">
    <Button android:text="@string/string_main_NewCalculation" android:drawableLeft="@drawable/calculator5" android:onClick="onClickButton_NewCalculation" android:id="@+id/button_main_NewCalculation" android:layout_width="300px" android:layout_height="90px" android:drawablePadding="0px"></Button>
    <Button android:text="@string/string_main_Help" android:drawableLeft="@drawable/question" android:onClick="onClickButton_Help" android:id="@+id/button_main_Help" android:layout_width="150px" android:layout_height="90px" android:drawablePadding="0px" android:layout_below="@id/button_main_NewCalculation"></Button>
    <Button android:text="@string/string_main_Share" android:drawableLeft="@drawable/share" android:onClick="onClickButton_Share" android:id="@+id/button_main_Share" android:layout_width="150px" android:layout_height="90px" android:drawablePadding="0px" android:layout_below="@id/button_main_NewCalculation" android:layout_toRightOf="@id/button_main_Help"></Button>
</RelativeLayout>
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/layout_maintest2_relativelayoutright" android:layout_toRightOf="@id/layout_maintest2_relativelayoutleft" android:layout_alignTop="@id/layout_maintest2_relativelayoutleft">
    <TextView android:layout_width="wrap_content" android:textSize="24px" android:textStyle="bold" android:layout_height="match_parent" android:id="@+id/textView_calculator_CalculatorTitle" android:text="@string/string_calculator_CalculatorTitle"></TextView>
</RelativeLayout>
</LinearLayout>

Its hard to tell from the image you uploaded but are you trying to keep the two relative layouts side by side? 很难从您上传的图像中分辨出来,但是您是否试图将两个相对的布局并排放置?

You can try to position the layouts by declaring them to be drawn to one side of the parent or the other. 您可以通过声明要绘制到父级或另一侧的一侧来尝试放置布局。 I cant remember off the top of my head at the moment and I know thats a crappy answer but I think the answer is somewhere in here 我现在不记得我的头顶了,我知道那是一个糟糕的答案,但我认为答案就在这里

http://developer.android.com/guide/topics/ui/layout-objects.html http://developer.android.com/guide/topics/ui/layout-objects.html

Take a look at the android:layout_alignParentRight="true" declaration. 看一下android:layout_alignParentRight =“ true”声明。

Im pretty sure I used something similar to position multiple views and buttons in the same parent before. 我很确定我之前使用过类似的方法来将多个视图和按钮放置在同一父对象中。 Try it out and when I get back to my work computer on monday Ill look through my projects and see which one I know works the best. 尝试一下,当我星期一回到工作计算机时,我会仔细检查我的项目,看看我知道哪个项目效果最好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM