传说和字段集的机器人 [英] legend and fieldset in android

查看:164
本文介绍了传说和字段集的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能在Android中做这样的形式:

I want to know if it's possible in android to do a form like that :

在这一刻,我做了一个形状产生的边界(我用这个形状,我的LinearLayout的背景下,但我不知道如何处理文本)。

At this moment, I made a shape to produce the border (I use this shape as a background of my linearlayout, but i don't know how to deal with the text).

在此先感谢。

推荐答案

我设法使用下面的方法来获取与标题的框架。

I have managed to get a frame with title using the following technique.

  1. 使用的FrameLayout 的整体布局。

里面添加其他布局的主要内容 - 这可以是任何东西。此布局的背景下,使用自定义XML绘制与笔画来绘制框架。确保新增利润在此布局,特别是 marginTop ,因为你需要一些空间来显示框的标题。另外补充一些填充,使之看起来更好。

Inside add another layout for your main content - this can be anything. For the background of this layout, use a custom XML drawable with stroke to draw the frame. Make sure to add margins in this layout, especially marginTop, as you need some room to display the title of the frame. Also add some padding to make it look nicer.

使用的TextView 与不透明的背景和一些垫作为标题。设置 marginLeft 上到一个合理的值,以抵消从左边的称号。

Use TextView with opaque background and some paddings as the title. Set marginLeft on it to a reasonable value to offset the title from the left.

下面是我的XML进行这样的:

Here's my XML for this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="@android:color/white">

    <!--  This is the main content -->
    <RelativeLayout
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_margin="15dp" android:background="@drawable/frame"
        android:orientation="vertical" android:padding="20dp">

        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:text="Main Content" android:layout_centerInParent="true" />

    </RelativeLayout>

    <!--  This is the title label -->
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:background="@android:color/white" android:padding="5dp"
        android:text="Testing"
        android:layout_marginLeft="30dp" android:textColor="@android:color/black" />

</RelativeLayout>

当执行时,我得到这个上的应用程序:

When executed, I get this on the app:

随意调整边距/补白对齐标题,你需要的方式。

Feel free to tweak the margins/paddings to align the title the way you need.

这篇关于传说和字段集的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆