-4

1 つの XML ファイルで 2 つの画像を使用する必要があるアプリケーションを作成しています。(1 つはロゴ用で、もう 1 つはログイン パターンです) . パターン画像では、2 つの EditText を設定する必要があります。これどうやってするの???

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
<ImageView
.
.
.
.
./>

          <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/some image" 
            android:layout_marginLeft="200dp"
            android:layout_marginBottom="300dp"
            android:layout_marginTop="80dp">  

           <LinearLayout 
            android:layout_height="fill_parent"
            android:layout_width="fill_parent" 
            android:layout_weight="1"
            android:gravity="center" 
            android:orientation="vertical">
            <EditText 
             android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
                           />
        </LinearLayout>
    </RelativeLayout>
    </relativeLayout>
4

4 に答える 4

2

私がこれを正しく理解している場合、基本的には、フォアグラウンドに 2 つの EditText があるバックグラウンドが必要です。

これを行う最善の方法は、相対レイアウトを使用することです。このようなものが動作します (注、これは疑似コードであるため、直接動作しません)。

<RelativeLayout>

    <ImageView
        android:height="fill_parent"
        android:src="@drawable/some_image"
        android:width="fill_parent" />

    <EditText
        android:id="@+id/edit_text1"
        android:layout_alignParentBottom="true" />

    <EditText
        android:id="@+id/edit_text2 "
        android:layout_above="@id/edit_text1" />

</RelativeLayout>
于 2012-11-25T20:44:49.887 に答える
1

あなたの質問は少しあいまいですが、Relativelayoutを使用して EditTexts を ImageView の上に簡単に配置できます。

基本的な例は次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/image" />

</RelativeLayout>
于 2012-11-25T20:40:52.383 に答える
0

画像ビューの上に編集テキストを配置するには:

EditText edit = (EditText)findViewById(R.id.YOUR_EDITTEXT_ID);
ImageView image = (ImageView)findViewById(R.id.YOUR_IMAGEVIEW_ID);
image.setImageBitmap(YOUR_BITMAP);
edit.bringToFront();

上記のコードは、編集テキストを z 軸に沿ってイメージビューの上に移動します。もちろん、それらを XML またはプログラムで配置する必要があります。

于 2012-11-25T20:43:52.110 に答える
0

ご協力ありがとうございました。私は自分の仕事を完了しました..このアプリケーションはタブレット用ですので、それに応じて余白を確認してください. ここにコードがあります..

<?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="match_parent"
    android:orientation="vertical"
    android:background="#fff"

<ImageView
    android:id="@+id/login"
    android:layout_width="648dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="640dp"
    android:layout_marginTop="40dp"
    android:src="@drawable/ic_login" />

<EditText 
    android:id="@+id/et1"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:cursorVisible="true"
    android:background="#000"
    android:singleLine="true"
    android:layout_marginTop="100dp"
    android:layout_marginLeft="710dp"
    android:layout_marginRight="193dp"
    android:textColor="#fff"/>

<EditText 
    android:id="@+id/et1"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:cursorVisible="true"
    android:background="#000000"
    android:singleLine="true"
    android:layout_marginTop="127dp"
    android:layout_marginLeft="710dp"
    android:layout_marginRight="193dp"
    android:textColor="#fff"/>

<ImageView 
     android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="420dp"
    android:layout_marginLeft="2dp"
    android:src="@drawable/ic_glogo" />


 </RelativeLayout> 
于 2012-11-26T09:55:26.237 に答える