簡體   English   中英

三星Galaxy Nexus S3渲染視圖對象時出現問題(多個問題)

[英]Samsung Galaxy Nexus S3 issues rendering View Objects (multiple issues)

  1. 設備:三星Galaxy Nexus
  2. 安裝:設備大部分為空白,僅用於開發
  3. Android版本:4.2.2

所以我今天開始工作一個項目。 我注意到,當我使用屏幕鍵盤上的默認值鍵入EditText object ,不僅設置的提示沒有消失,而且鍵入的每個字符的兩邊都有白色豎線。

我弄亂了屬性(盡管除了通過XML添加EditText的最少操作外,我幾乎什么都沒做)。 過了一會兒,我將apk發送給同事,並請他在他的設備(不是Galaxy Nexus)上運行它。 他發送給我的屏幕截圖沒有顯示此類錯誤。 我決定忽略它並繼續前進。

我剩下的日子一直是奇怪的問題,實際上不應該發生。 一個例子是我有一個帶有片段的Activity,在完成任務后,我試圖簡單地切掉片段。 (將它們以編程方式添加到活動布局中的FrameLayout ViewGroup中(在其他方法失敗之后))。 將添加新的片段,但舊的片段仍會顯示。 按下主屏幕/最近的按鈕,然后返回到應用程序,則刪除了根本不應該顯示的片段。 然后,我決定簡單地更改用於設置活動的setContentView的布局文件,而不是切換活動。 結果相同。 我試圖自己給contentView視圖充氣,然后再調用View.setVisible(View.GONE) (以后也嘗試View.INVISIBLE )。 沒有運氣。 同樣值得一提的是,調用無效(幾乎可以想到的任何事情)也不會使刪除的內容消失。

所以我想我的問題是,到底是什么原因造成了所有這些混亂? 有沒有人遇到過這樣的問題?

當前活動代碼(到目前為止,唯一的方法是onCreate()):

private View layout1, layout2;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    super.requestWindowFeature(Window.FEATURE_NO_TITLE);

    LayoutInflater factory = getLayoutInflater();
    layout1 = factory.inflate(R.layout.building_list, null);
    layout2 = factory.inflate(R.layout.activity_files, null);
    super.setContentView(layout1);

    new Thread(new Runnable()
    {
        @Override
        public void run()
        {
            try{Thread.sleep(1000);}
            catch(Exception e){}

            runOnUiThread(new Runnable()
            {
                @Override
                public void run()
                {
                    FilesActivity.this.setContentView(layout2);
                }
            });
        }
    }).start();
}

布局1的XML代碼:

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

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/pin_wheel"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="44dp"
        android:text="@string/building_list_text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <ProgressBar
        android:id="@+id/pin_wheel"
        style="@android:style/Widget.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />
</RelativeLayout>

用於layout2的XML代碼:

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

    <TextView
        android:id="@+id/files_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="28dp"
        android:text="@string/files_title"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="List Of Files Go here"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

如果其他人有奇怪的渲染問題。 如文字顯示不正確。 已刪除的View對象繼續顯示(我敢肯定還有很多)。 您應該嘗試將應用程序的基本主題更改為其他內容(對於其他應用程序,很可能位於res / values / styles.xml)。 還要檢查清單文件中列出的所有活動是否確實使用了您認為正在使用的主題(如果您未設置每個活動的主題,請確保已將需要特定樣式的View對象設置為這樣)。

例:

    <activity
        android:name=".MainActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" > <!-- this line, if you are using a custom theme it should be used here-->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM