Android, добавляющий динамические ImageViews в HorizontalScrollView, не работает

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

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

<!-- 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);
                }

person user2312798    schedule 15.01.2015    source источник


Ответы (1)


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

person medhdj    schedule 15.01.2015
comment
спасибо @medhdj: применение `android:layout_width=wrap_content` к обоим HorizontalScrollView и LinearLayout сработало для меня :) - person user2312798; 19.01.2015