2016-01-13 69 views
1

我已經與Android工作室發揮各地,只是不知道爲什麼渲染的結果是什麼,我創建 Here is the image of my screen, you can see that the 2 screen of Android Studio and Genymotion are completely different爲什麼Emulator向Android Studio呈現不同的結果?

這裏是佈局的XML文件,以便不同的,基本上我只是拖動和調整幅度,寬度和高度。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
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" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="tk.miendatmoi.widgetexperiments.WidgetExperimentsActivity" 
tools:showIn="@layout/activity_widget_experiments" 
android:visibility="visible"> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Left Button" 
    android:id="@+id/button" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:width="150dp" 
    android:layout_marginLeft="10dp" 
    android:layout_marginTop="100dp" 
    android:layout_marginRight="50dp" 
    android:layout_marginBottom="50dp" /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Right" 
    android:id="@+id/button2" 
    android:layout_alignBottom="@+id/button" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:width="80dp" /> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="New Text" 
    android:id="@+id/textView" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    android:textSize="65sp" 
    android:width="150dp" 
    android:height="150dp" 
    android:gravity="center" 
    android:alpha=".5" 
    android:background="#342a2a" 
    android:textColor="#fdfdfd" 
    android:typeface="serif" 
    android:visibility="visible" /> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageView" 
    android:layout_below="@+id/textView" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="45dp" 
    android:src="@android:mipmap/sym_def_app_icon" 
    android:contentDescription="incon" /> 

</RelativeLayout> 

回答

-1

模擬器中的結果與Android Studio預覽不同,因爲您正在小部件中顯示佈局。 Android Studio佈局預覽中的工具無法在小部件內部顯示佈局,因此它們將顯示佈局,就好像它被允許佔據整個屏幕一樣。在運行應用程序時,它在窗口小部件中正確顯示的佈局。

1

這是因爲您正在使用兩種不同的佈局。看起來像genymotion佈局是使用平板電腦佈局,它有一個不同的分辨率,是在使用nexus 4分辨率的android工作室。

+0

我其實在手機和平​​板電腦模擬器中都嘗試過這種佈局代碼。這不是屏幕分辨率的問題,因爲兩個模擬器都顯示了David鏈接中的佈局。 –

相關問題