0

I give view height according to percentage of screen. But views only get integer value. How can I convert integer values without rounding the numbers. I calculate according to the screen. As the double values turn integer values, the roundings are blank on the screen.

public class TutorialFragment extends BaseFragment { private double mScreenHeight; private double bgBlueHeight; private double bgGrayHeight; private double textHeight; private double mPathHeight; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_tutorial, container, false); setTutorialPages(); return mView; } private void setBackgroundGray() { ImageView bgGray = (ImageView) mView.findViewById(R.id.bg_gray_tutorial); bgGray.getLayoutParams().height = (int) bgGrayHeight; bgGray.requestLayout(); } private void setBackgroundBlue() { ImageView bgBlue = (ImageView) mView.findViewById(R.id.tutorial_dotted_blue_bg); bgBlue.getLayoutParams().height = (int) bgBlueHeight; bgBlue.requestLayout(); } private void defaultScreen() { DefaultScreen.sharedInstance(getContext()).setDefaultScreen(); mScreenHeight = DefaultScreen.sharedInstance(getContext()).getScreenHeight(); bgBlueHeight = mScreenHeight * 0.30; bgGrayHeight = mScreenHeight * 0.34; mPathHeight = mScreenHeight * 0.06; textHeight = mScreenHeight - bgBlueHeight - bgGrayHeight - mPathHeight; } private void setText(String text) { TextView textView = (TextView) mView.findViewById(R.id.txt_tutorial); textView.setText(text); textView.getLayoutParams().height = (int) textHeight; textView.requestLayout(); } private void setTutorialPages(){ defaultScreen(); setBackgroundBlue(); setBackgroundGray(); setPath(); } } 
3

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.