2015-01-15 2 views
0

Я отчаянно пытаюсь достичь этого в течение довольно долгого времени, но все еще не мог заставить его работать. У меня есть ListView, где внутри моего адаптера я пытаюсь динамически добавлять изображения в зависимости от моих данных. Но ScrollView не отображается с добавленными изображениями. Когда я попробовал myLinearLayout.getChildCount(), он дает правильные результаты!Android добавляет динамические ImageViews в HorizontalScrollView не работает

Что я делаю неправильно? Любая помощь очень ценится :)

<!-- ScrollView (This lies inside listView's child view) --> 
<HorizontalScrollView 
     android:id="@+id/card_txn_horizontal_scroll" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <LinearLayout 
      android:id="@+id/scroll_view_linear" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="horizontal" 
      android:background="@color/header_bg"> 
     </LinearLayout> 
</HorizontalScrollView> 

LinearLayout sharedWithView = (LinearLayout) convertView.findViewById(R.id.scroll_view_linear); 
for (User sharer : data.getSharerModelList()) { 
     ImageView mImageView = (ImageView) mInflator.inflate(R.layout.photo, null); 
     Picasso.with(mImageView.getContext()) 
      .load(expense.getPayeeModel().getProfilePicUrl()) 
      .centerCrop() 
      .resize(QuickReturnUtils.dp2px(mImageView.getContext(), 38), 
            QuickReturnUtils.dp2px(mImageView.getContext(), 38)) 
          .placeholder(R.drawable.ic_launcher) 
          .error(android.R.drawable.stat_notify_error) 
          .into(mImageView); 
        sharedWithView.addView(mImageView); 
       } 

ответ

1

попробовать android:layout_width="wrap_content" внутри в LinearLayout

+0

благодаря @medhdj: применение 'андроида: layout_width = "wrap_content"' и к '' HorizontalScrollView' и LinearLayout' работал для меня :) – user2312798

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