2016-07-15 11 views
2

mein Bild wird nicht Zentrum mit dem Code „android: layout_centerHorizontal“ auch mit der Schwerkraft wird es nicht lösen. Gibt es eine andere Möglichkeit oder gibt es falsche Eingaben in meiner Relaylayout- und Scroll-Ansicht?Bild wird nicht mit Android Zentrum: layout_centerHorizontal

scale layout bounds landscape view of with scale layout bounds Bildschirmgröße 768x1280 Nexus api23

ich Probleme mit Android-Version bin nicht 4 mit vielleicht ist diese api zu tun? seit meinem minimalen SDK ist Android-Version 2?

Hier ist der Code:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:fillViewport="true" 
android:layout_height="fill_parent"> 
<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.capstone.jmilibraryapp.Login"> 


<EditText 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/etUsername" 
    android:hint="Enter Sr-Code" 
    android:layout_below="@+id/imageView3" 
    android:layout_centerHorizontal="true" /> 
<ImageView 
    android:layout_centerHorizontal="true" 
    android:layout_width="500dp" 
    android:layout_height="200dp" 
    android:src="@drawable/jmilogo" 
    android:id="@+id/imageView3" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<EditText 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/etPassword" 
    android:inputType="textPassword" 
    android:hint="Password" 
    android:layout_below="@+id/etUsername" 
    android:layout_centerHorizontal="true" /> 

<Button 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/bLogin" 
    android:text="Log In" 
    android:layout_below="@+id/etPassword" 
    android:layout_alignLeft="@+id/etPassword" 
    android:layout_alignStart="@+id/etPassword" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:text="Log In as Guest" 
    android:id="@+id/guest" 
    android:layout_marginTop="20dp" 
    android:layout_below="@+id/bLogin" 
    android:layout_centerHorizontal="true" /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:text="Log In as Guest" 
    android:id="@+id/testinguser" 
    android:layout_marginTop="20dp" 
    android:layout_below="@+id/guest" 
    android:layout_centerHorizontal="true" 
    /> 


</RelativeLayout> 
</ScrollView> 
+0

, was Sie wollen ?? ich meine du willst dir imageview hinter den EditText stellen ?? –

+0

@uttampanchasara sir Ich habe ein Bild hinzugefügt Entschuldigung für die späte Antwort Ich habe eine langsame Internetverbindung zu Hause. –

Antwort

0

Wahrscheinlich haben Sie Ihr Bild DO NOT das gleiche Verhältnis von Ihrem Image, können Sie überprüfen, es showLayoutBounds in den Entwickler-Tool in dem Gerät ermöglicht. Sie sehen die tatsächliche Größe von imageView.

zu lösen, dass man Ihnen eine Imagescaletype = „Fitcenter“, um Ihr Image proportional zu Ihrem Image oder Anzeige zu machen.

+0

ja sollte ich wahrscheinlich eine Bildgröße ändern? Ich habe meinen Beitrag übrigens aktualisiert vielleicht habe ich ein Problem mit API-Versionen? –

+0

@earlcabanig entfernen android: layout_alignParentLeft = "true" android: layout_alignParentStart = "true" aus dem Image. Es überschreibt das centreHorizontal-Verhalten. – jonathanrz

+1

das ist die Antwort, ich habe, aber scheinen kann öffentlich die Punktzahl aufgrund meines guten Ruf unter 15.em Danke übrigens zu sehen ^^ –

0

Try unter xml ist diese Arbeit mit mir ..

Outout

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_centerHorizontal="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="20dp" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="wrap_content" 
      android:layout_height="200dp" 
      android:layout_gravity="center_horizontal" 
      android:layout_weight="1" 
      android:scaleType="fitCenter" 
      android:src="@drawable/school" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginTop="20dp" 
      android:layout_weight="1"> 

      <EditText 
       android:id="@+id/etUsername" 
       android:layout_width="300dp" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:hint="Enter Sr-Code" /> 

      <EditText 
       android:id="@+id/etPassword" 
       android:layout_width="300dp" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/etUsername" 
       android:layout_centerHorizontal="true" 
       android:hint="Password" 
       android:inputType="textPassword" /> 

      <Button 
       android:id="@+id/bLogin" 
       android:layout_width="300dp" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/etPassword" 
       android:layout_alignStart="@+id/etPassword" 
       android:layout_below="@+id/etPassword" 
       android:text="Log In" /> 

      <TextView 
       android:id="@+id/guest" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/bLogin" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="20dp" 
       android:text="Log In as Guest" 
       android:textAppearance="?android:attr/textAppearanceSmall"/> 

      <TextView 
       android:id="@+id/testinguser" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/guest" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="20dp" 
       android:text="Log In as Guest" 
       android:textAppearance="?android:attr/textAppearanceSmall"/> 

     </RelativeLayout> 
    </LinearLayout> 
</ScrollView> 
+0

sir ich Ihren Code versucht, und ich bekomme diese Fehlermeldung "java.lang.RuntimeException: Nicht imstande, Start Aktivität ComponentInfo {com.capstone.jmilibraryapp/com.capstone.jmilibraryapp.Login}: java.lang.ClassCastException: android.support.v7.widget.AppCompatImageView kann nicht auf android.widget.EditText bei android.app gegossen werden. ActivityThread.performLaunchActivity (ActivityThread.java:2416) "Vielleicht habe ich Probleme mit appcompactview? –

+0

Ich habe meinen Beitrag aktualisiert Bitte lesen Sie es danke ^^ –

+0

versuchen Sie, suport Bibliothek 7 ur mit älteren Version verwenden –