我必须垂直滚动webview内容,使用scrollview包围的标签,在webview最初隐藏的意义上,当触摸事件发生时,包含的webview必须在两个方向上看到滚动控件,但它不能垂直滚动,任何人都帮助我解决它...... 这里是xml代码
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
</RelativeLayout>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_above="@+id/jr_lb_view_preview_gallery">
<ProgressBar android:id="@+id/jr_lb_progress_small"
android:layout_centerInParent="true" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/pb" />
<WebView android:id="@+id/jr_lb_view_preview_switcher"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="none" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginBottom="5dip" android:gravity="center">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/jr_lb_content_price"
android:textSize="12sp" android:textColor="@color/white"
android:background="@drawable/black_r_corner" android:typeface="sans" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Free Shipping!"
android:textSize="12sp" android:textColor="@color/author_color"
android:typeface="sans" android:layout_marginLeft="15dip" />
</LinearLayout>
<View android:layout_width="310dip" android:layout_height="1dip"
android:background="#FF909090" />
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/jr_lb_summary_grid" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numColumns="4"
android:columnWidth="75dip" android:scrollbars="none"
android:gravity="center" android:listSelector="@drawable/corner_orange1"
android:layout_marginTop="5dip" />
<View android:layout_width="310dip" android:layout_height="1dip"
android:background="#FF909090" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Details"
android:textSize="20sp" android:textColor="@color/author_color"
android:typeface="sans" />
<View android:layout_width="310dip" android:layout_height="1dip"
android:background="#FF909090" />
<WebView android:id="@+id/jr_lb_content_tv"
android:textSize="15sp" android:textColor="@color/black"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
</LinearLayout>
</ScrollView>
答案 0 :(得分:0)
试试这个java代码......我希望它对你有用
LinearLayout layout=new LinearLayout(this);
LayoutParams layoutParam=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(new ScrollView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
layout.setOrientation(LinearLayout.VERTICAL);
WebView detailsView=(WebView)findViewById(R.layout.jr_lb_view_preview_switcher);
layout.addView(detailsView, layoutParam);
detailsView.setVerticalScrollBarEnabled(true);
ScrollView scroll=new ScrollView(this);
scroll.addView(layout);
setContentView(scroll);
答案 1 :(得分:0)
制作像这样的缩放类
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class Zoom extends View {
private Drawable image;
ImageButton img,img1;
private int zoomControler=20;
public Zoom(Context context)
{
super(context);
image=context.getResources().getDrawable(R.drawable.j);
//image=context.getResources().getDrawable(R.drawable.icon);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
//here u can control the width and height of the images........ this line is very important
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
image.draw(canvas);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_DPAD_UP)// zoom in
zoomControler+=10;
if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN) // zoom out
zoomControler-=10;
if(zoomControler<10)
zoomControler=10;
invalidate();
return true;
}
并像
一样使用它 setContentView(new Zoom(this));