2016-04-05 20 views
-4

を変更することはできません:は、私はこのようなXMLファイルを構築したいアンドロイドXMLファイル

enter image description here

しかし、私はできません。誰かがなぜこれが起こるか教えてもらえますか?エディットボックスヒントの中心を作る方法?

特別編集ボックス

enter image description here

ここに私のコードです:

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

      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <Button 
        android:id="@+id/button1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="Button1" 
        android:layout_marginTop="67dp" 
        android:layout_below="@+id/linearLayout" 
        android:layout_centerHorizontal="true" 
        android:background="#013567" /> 

       <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="10dip" 
        android:gravity="center" 
        android:layout_marginTop="51dp" 
        android:id="@+id/linearLayout" 
        android:weightSum="1" 
        android:layout_below="@+id/textView4" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true"> 
        <!-- Email Label --> 
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceLarge" 
         android:text="Large Text" 
         android:id="@+id/textView" 
         android:layout_below="@+id/topBar" 
         android:layout_centerHorizontal="true" 
         android:textColor="#fe9900" 
         android:layout_weight="0.07" 
         android:layout_gravity="center_horizontal" /> 

        <EditText android:layout_width="268dp" 
         android:layout_height="match_parent" 
         android:layout_marginTop="5dip" 
         android:layout_marginBottom="20dip" 
         android:singleLine="true" 
         android:background="#ffffff" 
         android:hint="Enter Email Address" /> 
        <!-- Password Label --> 
        <EditText android:layout_width="274dp" 
         android:layout_height="fill_parent" 
         android:layout_marginTop="5dip" 
         android:singleLine="true" 
         android:password="true" 
         android:background="#ffffff" 
         android:hint="Password" /> 
        <!-- Login button --> 
        <Button android:id="@+id/btnLogin" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="10dip" 
         android:text="Login" 
         android:background="#fe9900" 
         android:layout_gravity="center_horizontal" /> 

        <!-- Link to Registration Screen --> 

       </LinearLayout> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginTop="45dp" 
        android:id="@+id/linearLayout2"> 


       </LinearLayout> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView2" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="41dp" 
        android:layout_marginStart="41dp" 
        android:layout_marginBottom="38dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView3" 
        android:layout_alignBottom="@+id/textView2" 
        android:layout_toRightOf="@+id/textView2" 
        android:layout_toEndOf="@+id/textView2" 
        android:layout_marginLeft="31dp" 
        android:layout_marginStart="31dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView4" 
        android:layout_alignTop="@+id/linearLayout2" 
        android:layout_toLeftOf="@+id/textView3" 
        android:layout_toStartOf="@+id/textView3" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView5" 
        android:layout_alignTop="@+id/linearLayout2" 
        android:layout_alignLeft="@+id/textView3" 
        android:layout_alignStart="@+id/textView3" 
        android:layout_marginLeft="34dp" 
        android:layout_marginStart="34dp" /> 

      </RelativeLayout> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button" 
      android:background="#013469" /> 



    </RelativeLayout> 

</RelativeLayout> 
+0

ここにいくつかの問題があります。 ** 1 ** - 'fill_parent'は6年前に廃止されました。代わりに 'match_parent'を使用してください。 ** 2 ** - あなたは実際には必要ではなく、パフォーマンスに**影響を与える多くのネストされたレイアウトを使用します。 1つのRelativeLayoutが正しく使用されていれば、必要なだけです。そしてはるかに優れたパフォーマンスを発揮します。 –

答えて

0

あなたが中心と電子メールのTextViewからandroid:layout_centerHorizontal="true"を削除したいのEditText XMLでandroid:gravity="center_horizontal"を追加します。また、廃止予定のため、android:password="true"も削除する必要があります。ちょっとしたヒント、xmlコードの行が黄色のとき。それには問題があるかもしれません。その上にカーソルを置いてメッセージを見て、左側の電球をクリックすると、さらにオプションが表示されます。以下のようなものが動作するはずです。

<!-- Email Label --> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Large Text" 
       android:id="@+id/textView" 
       android:layout_below="@+id/topBar" 
       android:textColor="#fe9900" 
       android:layout_weight="0.07" 
       android:layout_gravity="center_horizontal" /> 

      <EditText android:layout_width="268dp" 
       android:layout_height="match_parent" 
       android:layout_marginTop="5dip" 
       android:layout_marginBottom="20dip" 
       android:singleLine="true" 
       android:background="#ffffff" 
       android:gravity="center_horizontal" 
       android:hint="Enter Email Address" /> 
      <!-- Password Label --> 
      <EditText android:layout_width="274dp" 
       android:layout_height="fill_parent" 
       android:layout_marginTop="5dip" 
       android:singleLine="true" 
       android:password="true" 
       android:gravity="center_horizontal" 
       android:background="#ffffff" 
       android:hint="Password" /> 
関連する問題