마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

원형 프로그래스바 안보임 문제

0 추천

원래 이상없이 잘 표시되던 원형 프로그래스바가 얼마 전부터 표시되지 않습니다. 아래와 같이 해당 부분만 따로 빼서 테스트를 해봤는데 이것 역시 표시가 안되네요.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_main"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#00000000"
        android:visibility="gone" />
    <Button
        android:id="@+id/btn_run"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Run"
        android:onClick="onClick"/>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
    ProgressBar mProgress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mProgress = (ProgressBar)findViewById(R.id.progress);
    }

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_run:
                if (mProgress.getVisibility() == View.GONE) mProgress.setVisibility(View.VISIBLE);
                else mProgress.setVisibility(View.GONE);
                break;
        }
    }
}

이 코드에서도 안보이는 걸 봐서는 안드로이드 스튜디오 업데이트에서 뭔가 바뀐게 아닌가 하는 생각도 드는데 잘 모르겠네요. 혹시 이 문제에 대해 아시거나 짐작가는 부분이 있는 분들께 도움 구합니다.

참고로 테스트 기기 환경은 갤노트2 버전 4.4.2 이구요. 안드로이드 스튜디오는 2.2.1 쓰고 있습니다. 다음은 gradle 정보입니다.

......

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        ......

        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        ......
    }

    ......
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
}

 

THK (2,360 포인트) 님이 2016년 10월 18일 질문
.................

2개의 답변

0 추천
 
채택된 답변
익명사용자 님이 2016년 10월 18일 답변
THK님이 2016년 10월 18일 채택됨
네 투명입니다. 원형 프로그래스바가 투명인 것이 아니라서 이부분이 문제인 것은 아닌 것 같은데요?
으음...저도 테스트 해보니 문제 없군요...
검색해 보니 스택에서 Handler를 쓰고 있네요.
http://stackoverflow.com/questions/19005014/visibility-of-progressbar
핸들러 적용해 보시고 문제 있는지 알려주세요

추가:다른스택에서는
It's probably due the fact that View.GONE will prevent the View from being drawn to the screen, while another View android:layout_align[POSITION] component may be defined to that View, so their position can't be calculated.

View.INVISIBLE will work cause it just make it invisible, but the View is still there and other View can calculate their position if the align is set to it
라는군요...
보내주신 링크 잘 보았습니다. 거기서는 UI 쓰레드 과부하로 해당 작업을 다른 쓰레드로 분산 시켜 줄 것을 이야기하고 있는데, 제가 첨부한 코드 보시면 아시겠지만 프로그래스바 출력 이외에 다른 작업이 없습니다.
"저도 테스트 해보니 문제 없군요..." 라고 말씀하신건 위에 제가 첨부한 코드로 테스트 해보신 건가요? 저는 첨부한 코드에서도 프로그래스바가 안보이는 상황이거든요.
밑에 추가된 다른 스택 내용 참고해서 gone 대신 invisible 써봤는데, 이역시 해결이 안됩니다. 신기하네요... 원래 잘 되던 코드가 왜 갑자기 안되는 것인지 ;
0 추천
설마... 했는데, 어처구니 없는 방법으로 해결했습니다. 테스트 기기 전원을 껃다 켜보니 프로그래스바가 뜨더군요. ^^;
엉터리같은 질문에도 도움주신 윗분께 감사드립니다.
THK (2,360 포인트) 님이 2016년 10월 18일 답변
...