ユーザーがEULAの一番下までスクロールしたら、「同意する」ボタンを表示するために、自分で行う必要がありました。弁護士、ね?
実際、@JackTurkyの答えのようにScrollViewではなくWebViewをオーバーライドすると、getBottom()ではなく、コンテンツの高さを取得するためにgetContentHeight()を呼び出すことができます。役に立たない。
これは私の包括的な解決策です。限り、これはすべてのAPIレベル1のものですので、どこでも動作するはずです。
EulaWebView mEulaContent;
Button mEulaAgreed;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.eula);
mEulaContent = (EulaWebView) findViewById(R.id.eula_content);
StaticHelpers.loadWebView(this, mEulaContent, R.raw.stylesheet, StaticHelpers.readRawTextFile(this, R.raw.eula), null);
mEulaContent.setVerticalScrollBarEnabled(true);
mEulaContent.setOnBottomReachedListener(this, 50);
mEulaAgreed = (Button) findViewById(R.id.eula_agreed);
mEulaAgreed.setOnClickListener(this);
mEulaAgreed.setVisibility(View.GONE);
}
@Override
public void onBottomReached(View v) {
mEulaAgreed.setVisibility(View.VISIBLE);
}
:ユーザーは「OnBottomReachedListenerを実装」クラスに(私はこのようにそれを呼び出すのWebViewの下にスクロールした後
public class EulaWebView extends WebView {
public EulaWebView(Context context)
{
this(context, null);
}
public EulaWebView(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public EulaWebView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
public OnBottomReachedListener mOnBottomReachedListener = null;
private int mMinDistance = 0;
/**
* Set the listener which will be called when the WebView is scrolled to within some
* margin of the bottom.
* @param bottomReachedListener
* @param allowedDifference
*/
public void setOnBottomReachedListener(OnBottomReachedListener bottomReachedListener, int allowedDifference) {
mOnBottomReachedListener = bottomReachedListener;
mMinDistance = allowedDifference;
}
/**
* Implement this interface if you want to be notified when the WebView has scrolled to the bottom.
*/
public interface OnBottomReachedListener {
void onBottomReached(View v);
}
@Override
protected void onScrollChanged(int left, int top, int oldLeft, int oldTop) {
if (mOnBottomReachedListener != null) {
if ((getContentHeight() - (top + getHeight())) <= mMinDistance)
mOnBottomReachedListener.onBottomReached(this);
}
super.onScrollChanged(left, top, oldLeft, oldTop);
}
}
は、私は、これは「同意する」ボタンを表示するために使用します
は一番下に到達するので、とき(あるいは、彼らはそれの50個のピクセル以内に取得するとき、この場合には、)「私は同意する」ボタンが表示されます。完全に(同様の問題のために私のために動作しませんでした
ウェブビューにはボタンの参照はありません。 – Daniel