android - 在 Framelayout 中添加两个相互接触的按钮

标签 android android-layout android-framelayout

我想在 FrameLayout 中逐个添加两个按钮,但它们应该相互接触。但是,我无法做到这一点。这是我的代码:

<FrameLayout
    android:id="@+id/lytOptions"
    android:layout_below="@id/imgLine"
    android:layout_width="fill_parent"        
    android:layout_height="wrap_content" 
    >

    <Button
        android:id="@+id/btnLogin"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/action_via_email"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

    <Button
        android:id="@+id/btnSignUp"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"            
        android:text="@string/action_sign_up"
        android:textColor="@android:color/white"
        android:textStyle="bold" />
</FrameLayout>

最佳答案

试试这个

        <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="49dp"
            android:text="Button" />

    </RelativeLayout>

得到这样的输出

enter image description here

关于android - 在 Framelayout 中添加两个相互接触的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15919465/

相关文章:

android - 如何在achartengine android中的饼图右侧显示图例

android - 以编程方式将 MATCH_PARENT 用于 FrameLayout 内的 RelativeLayout

android - 如何以编程方式在 FrameLayout 中的另一个 LinearLayout 下添加 LinearLayout?

android - 如何在没有用户交互的情况下以编程方式配对蓝牙设备?

android:自定义文本选择器

android - 适用于 Amazon Kindle HDX 7"高清屏幕的正确布局资源文件夹

android - Logcat 警告 :Drawable android:drawable/text_cursor_material has unresolved theme attributes

android - 错误:找不到ID为 'com.android.application'的插件

android - 现在不推荐使用 BluetoothAdapter.getDefaultAdapter() 我该使用什么?

java - 如何通过拖放将图像保留在布局中