2014-10-22 90 views
0

單擊登錄按鈕後會出現一個進度條微調控制器,我希望微調器後面的元素變暗或變暗,而微調器在屏幕上可見。我的佈局文件看起來像這樣目前:加載動畫期間變暗/昏暗的背景元素 - Android

<RelativeLayout 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="apps.kusasa.biz.MainActivity" > 

    <EditText 
     android:id="@+id/EditText01" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/editText2" 
     android:layout_alignLeft="@+id/editText2" 
     android:layout_alignRight="@+id/editText2" 
     android:ems="10" 
     android:hint="Username" 
     android:inputType="text" /> 

    <EditText 
     android:id="@+id/editText2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/loginBtn" 
     android:layout_centerHorizontal="true" 
     android:ems="10" 
     android:hint="Password" 
     android:inputType="textPassword" > 

     <requestFocus /> 
    </EditText> 

    <Button 
     android:id="@+id/loginBtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/EditText01" 
     android:layout_alignParentBottom="true" 
     android:layout_alignRight="@+id/EditText01" 
     android:layout_marginBottom="67dp" 
     android:text="Login" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/EditText01" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/pics_logo" /> 

    <ProgressBar 
     android:id="@+id/progressBar1" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/editText2" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="77dp" /> 

</RelativeLayout> 

我的按鈕單擊方法:

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.loginBtn: 
     spinner.setVisibility(View.VISIBLE); 
     // etc 
    } 
} 

如何實現這一目標?謝謝!

回答

1

當您的微調器與您想要調暗的元素佈局相同時,這將會很困難。我會將微調器移動到單獨的(父級)佈局,然後將Alpha背景顏色應用於相關佈局。 例如#99000000

+0

你會使用什麼類型的佈局? – 2014-10-22 12:34:27

+0

怎麼樣FrameLayout,然後你可以堆疊元素 – Carsten 2014-10-22 12:54:06

+0

這條路線提出了大量的問題,如framelayout不填滿屏幕,進度條微調不再停留在佈局的中間,以及其他需要更多解決方法的事情。 – 2014-10-22 14:46:56