我試圖調試一個視圖,我以編程方式創建。我希望能夠看到創建後的視圖的確切XML。Android查看查看XML編程
真的,我想是能夠做到像Log.d(TAG,view.toString())
而獲得類似這樣的輸出:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
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: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="sampleapp.example.com.tr221test.MainActivity">
<Button android:id="@+id/surveyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Take Survey!"/>
</RelativeLayout>
反正我有可以編程看到XML是一種觀點的東西?
這是爲了調試目的? –
確實。我敢肯定,我搞亂了一些視圖的添加順序 - 嘗試以編程方式重新創建現有的視圖。 –
請參閱CommonsWare的答案,以獲取適當工具的鏈接。 –