我正在创建我的LinearLayout视图View.Gone,但它仍占用空间并显示空白空间。 请帮帮我。
<LinearLayout
android:id="@+id/tvshow_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible" >
<RelativeLayout
android:id="@+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="36dp"
android:paddingLeft="14dp"
android:paddingRight="14dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:shadowColor="@color/RGB_100_220_220_220"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:singleLine="true"
android:text="@string/common_title_tvshows"
android:textColor="@color/RGB_100_5_5_5"
android:textSize="20dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/common_button_arrow_left"
android:clickable="true" />
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:background="@drawable/btn_detail_next_devider" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/common_button_arrow_right"
android:clickable="true" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="147dp"
android:layout_marginTop="10dp" >
<com.sec.msc.android.yosemite.ui.detailview.HorizontalListAdapterView
android:id="@+id/nestedlistview_tv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
在listview的getView方法中,将此linearlayout作为行,我正在这样做
holder.movielayout = (LinearLayout) convertView.findViewById(R.id.tvshow_layout);
holder.tvshowlayout.setVisibility(View.GONE);
ViewHolder holder;
if(convertView == null){
convertView = Inflater.inflate(mLayout, parent, false);
holder = new ViewHolder();
holder.movielayout = (LinearLayout) convertView.findViewById(R.id.seasonalfavorites_movie_layout);
holder.tvshowlayout = (LinearLayout) convertView.findViewById(R.id.seasonalfavorites_tvshow_layout);
holder.nestedMovieList = (HorizontalListAdapterView)convertView.findViewById(R.id.nestedlistview_movie);
holder.nestedTvList = (HorizontalListAdapterView)convertView.findViewById(R.id.nestedlistview_tv);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String title = mPromotionList.get(position).getPromotionTitle();
holder.titleText.setText(title);
movieItemList = (ArrayList<SeasonalFavoritesListItem>) mMovieMap.get(title);
tvItemList = (ArrayList<SeasonalFavoritesListItem>) mTvShowMap.get(title);
if(tvItemList.size()>0){
holder.tvshowlayout.setVisibility(View.VISIBLE);
SeasonalFavoritesHorizentalListAdapter listAdaptrTv = new SeasonalFavoritesHorizentalListAdapter(mContext,tvItemList,1,holder.nestedTvList);
holder.nestedTvList.setAdapter(listAdaptrTv);
}else{
holder.tvshowlayout.setVisibility(View.GONE);
}
if(movieItemList.size()>0){
holder.movielayout.setVisibility(View.VISIBLE);
SeasonalFavoritesHorizentalListAdapter listAdaptr = new SeasonalFavoritesHorizentalListAdapter(mContext,movieItemList,0,holder.nestedMovieList);
holder.nestedMovieList.setAdapter(listAdaptr);
}else{
holder.movielayout.setVisibility(View.GONE);
}
答案 0 :(得分:0)
我终于解决了这个问题。我的父布局有背景图片,正在占据空间。一旦我改变了它工作正常