2013-05-23 2 views
2

Я хочу добавить индикатор выполнения в середине моего изображения. Все компоненты, которые мне нужно добавить в код. Это код:Добавить индикатор выполнения для просмотра изображения в коде в android

ReloadableImageView imageView = null; 

    LayoutInflater inflater = getActivity().getLayoutInflater(); 
    for(PageInfo info: pagesInfo){ 
     if(!info.isVisible()) 
      continue; 
     info.setThumbnail(path + "/" + info.getPageNum() + ".jpg"); 
     inflater.inflate(R.layout.cell, null); 
     imageView = new ReloadableImageView(getActivity()); 

      LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 
                     LinearLayout.LayoutParams.WRAP_CONTENT); 
      lp.setMargins(10, 10, 10, 10); 
      imageView.setLayoutParams(lp); 

      imageView.setOnClickListener(clickListener); 
      imageView.setId(info.getPageNum()); 
      imageView.setBlur(info.requiresLogin()); 
      imageView.setImagePath(info.getThumbnail()); 
      views.append(info.getPageNum(), imageView); 
      mainLayout.addView(imageView); 
     } 

Как я могу добавить прогресс бар на мой взгляд изображения в коде? «mainLayout» - LinearLayout.

Edit:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="@android:color/transparent" > 

    <HorizontalScrollView 
     android:id="@+id/horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:background="#80000000" 
     > 

     <LinearLayout 
      android:id="@+id/_linearLayout" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:orientation="horizontal" > 
     </LinearLayout> 

    </HorizontalScrollView> 

       <ProgressBar 
        android:id="@+id/progressBar1" 
        style="?android:attr/progressBarStyleLarge" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_centerHorizontal="true" 
        android:visibility="visible" /> 

</RelativeLayout> 
+1

вы можете использовать относительный макет для этой цели – Raghunandan

+0

@ edi233 вы можете разместить свой код XML? – TheFlash

+0

Где изображение? –

ответ

4

Использование RelativeLayout для этой цели. После этого вы можете внести alignment корректировки в положение progressbar выше ImageView.

Кроме того, если вы динамически добавляете ImageView, динамически добавляйте индикатор выполнения.

Ниже приведен фрагмент кода, который устанавливает индикатор выполнения выше ImageView с выравниванием по центру:

<RelativeLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/image" /> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true"/> 
</RelativeLayout> 
+0

Добавить комментарий. – Raghunandan

+0

@ Raghunandan, но это решение этой проблемы –

+1

, а затем добавить фрагменты кода для поддержки вашего ответа. это выглядит скорее скорее предложением, чем ответом – Raghunandan

Смежные вопросы