2013-05-01 153 views
0

我无法在登录文本的顶部添加图像。如何将我的徽标图像添加到登录文本区域。也可以有人请帮我添加一个免费的textafter后3个按钮。 enter image description here在登录屏幕上添加图像

这里是我的这个

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 

    <RelativeLayout 
     android:id="@+id/register" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/jklogin4" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="20dp" 
      android:text="Login" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/textView1" 
      android:layout_marginLeft="18dp" 
      android:layout_marginTop="15dp" 
      android:text="Username" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/textView2" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="5dp" 
      android:ems="10" /> 

     <EditText 
      android:id="@+id/editText2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/editText1" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="20dp" 
      android:ems="10" /> 

     <Button 
      android:id="@+id/close" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/button2" 
      android:layout_alignBottom="@+id/button2" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="38dp" 
      android:background="@drawable/button_custom" 
      android:text="Cancel" /> 

     <Button 
      android:id="@+id/button1" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/textView3" 
      android:layout_below="@+id/editText2" 
      android:layout_marginTop="16dp" 
      android:background="@drawable/button_custom" 
      android:text=" Enter " /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/textView2" 
      android:layout_below="@+id/editText1" 
      android:text="Password" /> 

     <Button 
      android:id="@+id/button2" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/button1" 
      android:layout_alignBottom="@+id/button1" 
      android:layout_alignRight="@+id/textView1" 
      android:background="@drawable/button_custom" 
      android:text="Signup" /> 

    </RelativeLayout> 

</RelativeLayout> 

感谢

代码
+0

'请帮我添加免费textafter你想要的文字添加以下三个按钮或之后3个按钮的3个buttons'做什么? – GrIsHu 2013-05-01 04:31:47

+0

@Grishu在三个按钮之后。与三个长线一样的自由文本 – Yogus 2013-05-01 04:39:55

+0

您可以添加'TextView'并提供可以在您的'String.xml'文件中定义的文本,其中包含3个按钮。 – GrIsHu 2013-05-01 04:45:28

回答

0

试用中,我添加了图像上的TextView的顶部,还增加了TextView低于3 Buttons,你需要它我下面的布局代码。

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 

<RelativeLayout 
    android:id="@+id/register" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:background="@drawable/jklogin4" > 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="20dp" 
     android:text="Login" 
     android:drawableTop="@drawable/ic_launcher" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 
    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView1" 
     android:layout_marginLeft="18dp" 
     android:layout_marginTop="15dp" 
     android:text="Username" /> 
    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView2" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="5dp" 
     android:ems="10" /> 
    <EditText 
     android:id="@+id/editText2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/editText1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="20dp" 
     android:ems="10" /> 
    <Button 
     android:id="@+id/close" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/button2" 
     android:layout_alignBottom="@+id/button2" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="38dp" 
     android:background="@drawable/button_custom" 
     android:text="Cancel" /> 
    <Button 
     android:id="@+id/button1" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/textView3" 
     android:layout_below="@+id/editText2" 
     android:layout_marginTop="16dp" 
     android:background="@drawable/button_custom" 
     android:text=" Enter " /> 
    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/textView2" 
     android:layout_below="@+id/editText1" 
     android:text="Password" /> 
    <Button 
     android:id="@+id/button2" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/button1" 
     android:layout_alignBottom="@+id/button1" 
     android:layout_alignRight="@+id/textView1" 
     android:background="@drawable/button_custom" 
     android:text="Signup" /> 
</RelativeLayout> 
    <TextView 
     android:id="@+id/text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="18dp" 
     android:layout_marginRight="18dp" 
     android:layout_marginTop="15dp" 
     android:layout_below="@+id/register" 
     android:text="ajsfoiahoihaoihaoifhasf hsohaoishdiuasgdouhasofhsaodfhosahoaisdfoashdfohsdfoih" /> 
    </RelativeLayout> 
1

添加drawable top属性为您登录的TextView

即该属性

android:drawableTop="@drawable/ic_launcher" <-- Your drawable name 

添加到该

<TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="20dp" 
      android:text="Login" 
      android:textAppearance="?android:attr/textAppearanceMedium" />