键盘隐藏文本字段从WebView

时间:2016-09-15 09:45:53

标签: android android-layout android-studio android-fragments webview

我正在使用android WebView,下面是XML布局:

<ScrollView 
     android:layout_width="match_parent"     
     android:layout_height="match_parent"> 

    <WebView android:id="@+id/medical_webview" 
             android:layout_width="match_parent"  
             android:layout_height="wrap_content" 
             android:focusable="true" 
             android:focusableInTouchMode="true" 
             android:layout_alignParentTop="true"> 
     </WebView> 
</ScrollView>

WebView开始,textfield位于页面底部。一旦我们专注于文本字段,UI就不会自动向上滚动并隐藏文本字段。

更多信息,我正在使用Fragment并已尝试使用adjustResize|adjustPan

2 个答案:

答案 0 :(得分:0)

您必须在片段类中定义adjustresize | adjustpan而不是在清单中:

\documentclass[11pt]{article}
\usepackage{setspace}                                   %double spacing and spacing in tables                           
\usepackage{amsmath}                                    %equations etc. in latex
\usepackage[capposition=top]{floatrow}                  %so that the caption for figures appear at the top
\usepackage[tablename=TABLE,figurename = FIGURE,labelsep=newline,aboveskip=0pt,font=bf,justification=centering]{caption}   %so that caption looks cool
\usepackage{booktabs}                                   %midrule etc. which adds space around lines. Make tables look good. 
\usepackage{tabularx}                                   %use tabularx environment for creating one page tables
\usepackage[margin=1in]{geometry}                       %defining the margin for the page
\usepackage[autostyle]{csquotes}                        %for quotes. alternative would be " and "
\usepackage[table]{xcolor}                              %rowcolor, cellcolor, color for references
\usepackage{pdflscape}                                  %landscape and keep the pages straight
\usepackage{everypage}                                  %For AddEveryHookPage
\usepackage{hanging}                                    %For references
\usepackage{longtable}                                  %For multiple pages
\usepackage{multirow}                                   %Valuable package as can be seen from table 5,8, and 10
\usepackage{graphicx}                                   %created line using this package
\usepackage{bm}                                         %bold and italics in the math enviornment at the same time
\usepackage{dcolumn} % a package actually used in this example

\def\hang{\par\noindent\makebox[1.5em][l]{ }\hangindent1.5em} %hanging indent  

\makeatletter
\setlength{\@fptop}{0pt}                                %to make tables and figures start at the top of the page
\makeatother

\newcommand{\Lpagenumber}{\ifdim\textwidth=\linewidth\else\bgroup       %to correct the page numbering for landscape pages
    \dimendef\margin=0
    \ifodd\value{page}\margin=\oddsidemargin
    \else\margin=\evensidemargin
    \fi
    \raisebox{\dimexpr -\topmargin-\headheight-\headsep-0.5\linewidth}[0pt][0pt]{%
        \rlap{\hspace{\dimexpr \margin+\textheight+\footskip}%
            stabu            \llap{\rotatebox{90}{\thepage}}}}%
    \egroup\fi}
\AddEverypageHook{\Lpagenumber}%                        %to correct the page numbering for landscape pages


\newcolumntype{Y}{>{\centering\arraybackslash}X}        %to center the columns for tabularx environment
\newcolumntype{Z}{>{\centering\arraybackslash}p{0.75in}}    %to center the columns for tabularx environment
\newcolumntype{K}{>{\centering\arraybackslash}p{0.3in}} %to center the columns for tabularx environment
\newcommand{\gmc}[3]{\multicolumn{#1}{@{}#2@{}}{#3}}    %short form for multicolumn
\doublespacing                                          %make lines double spaced



\begin{document}
    \setcounter{page}{-1} %start numbering at page 3 (2 - n where n = -1)
    \thispagestyle{empty} %suppress page number

    \begingroup % keep any font size changes local to group
    \captionof{table}{\textbf{Descriptive Statistics}}
    \singlespacing
    \footnotesize
    \centering
    \setlength\tabcolsep{3pt} %default
    \renewcommand{\arraystretch}{1}


    \begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}l*{2}{c}}
        \gmc{3}{l}{\textbf{Panel A: Sample Representation across Economic Sectors}} \\\midrule   
        \textbf{Sector} & \textbf{N} & \textbf{\% Frequency} \\\midrule
        Energy & 524 & 1.65\%                       \\
        Materials & 2,648 & 8.34\%                  \\
        Industrials & 5,905   &     18.60\%             \\
        Consumer Discretionary & 5,549  & 17.48\%       \\
        Consumer Staples & 2,174 & 6.85\%       \\
        Health Care & 5,167 & 16.28\%               \\
        Financials & 0 & 0.00\%             \\
        Information Technology & 9,774 & 30.79\%        \\
        Telecommunication Services & 0 & 0.00\% \\
        Utilities & 0 & 0.00\%              \\\midrule
        Total & 31,741 & 100.00\%               \\\midrule
    \end{tabularx}
    \endgroup

\end{document} 

http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_RESIZE

删除scrollview并设置布局参数后,其工作:)

快乐编码!!!!

答案 1 :(得分:0)

我删除了Scrollview并添加了: getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

现在它正在运作