【问题标题】:How to make this custom imageview/textview?如何制作这个自定义的 imageview/textview?
【发布时间】:2017-03-21 11:56:56
【问题描述】:

我需要为此自定义布局:

在我使用内部带有editText 的自定义框架之前,但现在我需要一个大框架,所以我需要制作一个可绘制的。 问题是我不擅长drawables,我只做了这个布局:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:width="1dp"
        android:color="#EBEBE1" />

    <padding android:left="5dp"
        android:top="5dp"
        android:right="5dp"
        android:bottom="5dp"/>
</shape>

谁能帮我完成这个?

谢谢

【问题讨论】:

  • 我认为在背景中使用图像的最佳方式。如果我错了,请纠正我
  • @MayurRaval 我也这么认为,但问题是我使用了这么多内存而没有好的结果
  • 我同意 mayur,使用 9 补丁图像作为背景
  • “大”是什么意思?您可以使用editText,将文本添加为​​hint 属性并根据需要设置字体大小。
  • @TDG 因为图像的相框在像素上是有限的......在我使用这个相框和里面的editText之前,但在这种情况下它的布局很糟糕

标签: android android-layout imageview textview


【解决方案1】:

访问此链接以获取自定义文本视图:Custom Textview

【讨论】:

    【解决方案2】:

    我想是的,这是个好方法。

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_below="@id/layout1"
            android:layout_marginTop="20dp"
            >
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="15dp"
                android:background="#ffffff"
                android:hint="User Name / Email Address"
                android:textSize="20dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:drawableLeft="@drawable/login_user_icon"
                android:gravity="center_vertical"
                android:drawablePadding="5dp"
                android:id="@+id/etname"
                />
    
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="15dp"
                android:background="#ffffff"
                android:layout_below="@+id/etname"
                android:hint="Password"
                android:textSize="20dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:drawableLeft="@drawable/login_password_icon"
                android:drawablePadding="5dp"
                android:id="@+id/etpassword"
                android:inputType="textWebPassword"
                android:layout_marginTop="20dp"
                />
        </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 2012-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      相关资源
      最近更新 更多