0

I am stuck here, I used a Textview previously but the content is cut off at the bottom so I tried using a webview to display the contents inside a fragment using a Tabbed Activity which is my current view. This is the current output using a Tablet : Current

enter image description here

This is my xml code for the fragment

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp"
tools:context="org.gandroid.motif.Methods$PlaceholderFragment">

<WebView
    android:id="@+id/FPBriefsumm"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:background="@null"
    android:layout_weight="1"
    android:paddingBottom="2dp"
    />

and this is my java class for the fragment:

public class Methods_FamilyPlanning_brief extends Fragment {
TextView FPdesc,FPtitle;
WebView webView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_methods, container, false);

    webView = rootView.findViewById(R.id.FPBriefsumm);
    webView.loadUrl("file:///android_asset/familyplanning.html");
    webView.setBackgroundColor(Color.TRANSPARENT);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    // Force links and redirects to open in the WebView instead of in a browser
    webView.setWebViewClient(new WebViewClient());

I had tried all possible solutions from here:

  1. fragment-content-gets-cut-off
  2. android-listview-inside-fragment-gets-cut-off
  3. android-xml-cutting-off-bottom-half-of-layout
  4. android-studio-project-bottom-of-ui-is-cut-off Still no luck :( I tried it running on emulator and different physical devices but still the same. All I just wanna do is display a very long content in this fragment. Any idea would be great. Thanks in advance.

UPDATE : I tried @Mahesh answer it now looks like this. The last paragraph is missing.

My html code for the webview file.

<html>

Family Planning


Family planning is the practice of controlling the number of children in a family and the intervals between their births. Contemporary notions of family planning, however, tend to place a woman and her childbearing decisions at the center of the discussion, as notions of womens empowerment and reproductive autonomy have gained traction in many parts of the world. Family planning may involve consideration of the number of children a woman wishes to have, including the choice to have no children, as well as the age at which she wishes to have them. These matters are influenced by external factors such as marital situation, career considerations, financial position, any disabilities that may affect their ability to have children and raise them, besides many other considerations.

If sexually active, family planning may involve the use of contraception and other techniques to control the timing of reproduction. Other techniques commonly used include sexuality education, prevention and management of sexually transmitted infections,pre-conception counseling and management, and infertility management.

Family planning is sometimes used as a synonym or euphemism for access to and the use of contraception. However, it often involves methods and practices in addition to contraception. Additionally, there are many who might wish to use contraception but are not, necessarily, planning a family (e.g., unmarried adolescents, young married couples delaying childbearing while building a career); family planning has become a catch-all phrase for much of the work undertaken in this realm. It is most usually applied to a female-male couple who wish to limit the number of children they have and/or to control the timing of pregnancy (also known as spacing children).

Do you know when your last menstrual period began or how long it lasted? If not, it might be time to start paying attention.

Tracking your menstrual cycles can help you understand what's normal for you, time ovulation and identify important changes — such as a missed period or unpredictable menstrual bleeding. While menstrual cycle irregularities usually aren't serious, sometimes they can signal health problems.


What's the menstrual cycle?

The menstrual cycle is the monthly series of changes a woman's body goes through in preparation for the possibility of pregnancy. Each month, one of the ovaries releases an egg — a process called ovulation. At the same time, hormonal changes prepare the uterus for pregnancy. If ovulation takes place and the egg isn't fertilized, the lining of the uterus sheds through the vagina. This is a menstrual period.


What's normal?

The menstrual cycle, which is counted from the first day of one period to the first day of the next, isn't the same for every woman. Menstrual flow might occur every 21 to 35 days and last two to seven days. For the first few years after menstruation begins, long cycles are common. However, menstrual cycles tend to shorten and become more regular as you age.

Your menstrual cycle might be regular — about the same length every month — or somewhat irregular, and your period might be light or heavy, painful or pain-free, long or short, and still be considered normal. Within a broad range, "normal" is what's normal for you.

Keep in mind that use of certain types of contraception, such as extended-cycle birth control pills and intrauterine devices (IUDs), will alter your menstrual cycle. Talk to your health care provider about what to expect.

When you get close to menopause, your cycle might become irregular again. However, because the risk of uterine cancer increases as you age, discuss any irregular bleeding around menopause with your health care provider.

</body>
</html>
Nemus
  • 3,879
  • 12
  • 38
  • 57
Cytherie
  • 1
  • 4
  • Why you have given padding in webview remove that and try. – Mahesh Jan 18 '18 at 11:04
  • i just tried it based on the solutions given on some related thread it is still the same sir :( – Cytherie Jan 18 '18 at 11:09
  • Try changing the webview height to match_parent and not 0dp. Setting to OverviewMode and WideViewPort will force resize the content might make it unreadable. – Raanan Jan 18 '18 at 12:08

1 Answers1

0
Please try this.

webView .getSettings().setLoadWithOverviewMode(true); 
webView .getSettings().setUseWideViewPort(true);
Mahesh
  • 1,559
  • 6
  • 27
  • 57
  • sir I still have one paragraph left – Cytherie Jan 18 '18 at 11:23
  • I tried deleting some of the
    tags on my html file. the content is now unscrollable because the content is now smaller than the view size but the last paragraph is still missing. I don't have an idea what seems to be the problem. ill add a screenshot above sir
    – Cytherie Jan 18 '18 at 11:38
  • might be the issue in your html open that html in browser it is display correct or not ? – Mahesh Jan 18 '18 at 11:53
  • omg sir i just noticed that the content is complete. lol im sorry my bad. Thank you so much sir! Marked as answer. – Cytherie Jan 18 '18 at 12:03
  • sir 1 more thing, if i change the font size in my html file because it is too small it starts cutting off again the bottom contents. – Cytherie Jan 18 '18 at 12:34
  • is it scrolling ? – Mahesh Jan 22 '18 at 18:09