0
我有一个强制需要它的滚动视图。在滚动视图中,我有一个ListView。 listview的行项目有一个framlayout。广告准备就绪时,我将nativeexpreesview添加到fram布局。动态添加视图的列表视图的原始项目与滚动视图不工作android
现在的问题是,如果列表有10个项目时,广告未加载其作品好,但是当广告加载,然后它占据一定的高度,因为我将它添加到框架布局,然后滚动视图滚动只有广告前的列表高度广告加载。
,但我想用以及广告
整个项目滚动我acivity'slayout低于
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svStrategy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/app_bg"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<LinearLayout
android:id="@+id/lytBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_gravity="center"
android:text="@string/str_use_spells_best"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:textColor="@android:color/white" />
<ImageView
android:id="@+id/ivBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:adjustViewBounds="true" />
</LinearLayout>
<com.example.SummonersWar.classes.NestedListView
android:id="@+id/lvStrategy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:cacheColorHint="#00000000"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:fadingEdge="none"
android:focusable="false"
android:scrollbars="none" />
</LinearLayout>
</ScrollView>
Nestedlistview的Row_layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/lytStrategyRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:id="@+id/ivStrategyIcon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.4"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvStrategyTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:layout_weight="0.6"
android:ellipsize="end"
android:maxLines="4"
android:minLines="4"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textColor="@android:color/white" />
</LinearLayout>
<LinearLayout
android:id="@+id/rlads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lytStrategyRow"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="@android:color/transparent" />
<FrameLayout
android:id="@+id/fr_adview"
android:layout_width="match_parent"
android:layout_height="wrap_content"></FrameLayout>
</LinearLayout>
</RelativeLayout>
我编程添加Nativeexpressview到framlayout当广告被加载。
我nestedlistview下面
public class NestedListView extends ListView implements OnScrollListener // OnTouchListener
{
private int listViewTouchAction;
private static final int MAXIMUM_LIST_ITEMS_VIEWABLE = 100;
public NestedListView(Context context, AttributeSet attrs) {
super(context, attrs);
listViewTouchAction = -1;
setOnScrollListener(this);
// setOnTouchListener(this);
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (getAdapter() != null
&& getAdapter().getCount() > MAXIMUM_LIST_ITEMS_VIEWABLE) {
if (listViewTouchAction == MotionEvent.ACTION_MOVE) {
scrollBy(0, -1);
}
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int newHeight = 0;
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (heightMode != MeasureSpec.EXACTLY) {
ListAdapter listAdapter = getAdapter();
if (listAdapter != null && !listAdapter.isEmpty()) {
int listPosition = 0;
for (listPosition = 0; listPosition < listAdapter.getCount()
&& listPosition < MAXIMUM_LIST_ITEMS_VIEWABLE; listPosition++) {
View listItem = listAdapter.getView(listPosition, null,
this);
// now it will not throw a NPE if listItem is a ViewGroup
// instance
if (listItem instanceof ViewGroup) {
listItem.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
}
listItem.measure(widthMeasureSpec, heightMeasureSpec);
newHeight += listItem.getMeasuredHeight();
}
newHeight += getDividerHeight() * listPosition;
newHeight += getPaddingBottom() + getPaddingTop();
}
if ((heightMode == MeasureSpec.AT_MOST) && (newHeight > heightSize)) {
if (newHeight > heightSize) {
newHeight = heightSize;
}
}
} else {
newHeight = getMeasuredHeight();
}
setMeasuredDimension(getMeasuredWidth(), newHeight);
}}
所以我的问题是滚动型滚动唯一上榜的高度时,广告的.so加载,请帮助我我应该怎么滚动整个列表与广告现在怎么办?
使用可以在你的布局文件设置自定义滚动型,以及它的工作适当 – Chetna
没有在我的情况下工作@Chetna – sunita
你在XML文件中设置 – Chetna