-2

I wanna make two horizantal Layout which the bottom one is for placing base numbers and the top one is the place for Power of the numbers which should appear like this : 1²1²1² I'm using two editText . One for Subscript and the Other one for SuperScript . and there is also a button and a TextView which shows the result by clicking on the button . My code : enter image description here Result :| :

enter image description here

what's your idea about doing this ?

  • Please explain what you mean, exactly. Do you really need two "horizontal Layout[s]", or do you just want to be able to show superscript exponents? – Mike M. Jul 25 '16 at 13:21
  • No . I just want to get and save some math and physic formuls from user which may contains subscript and superscript nmubers and symbols – Alireza Imani Jul 25 '16 at 13:30
  • Well, there are a few basic examples of super- and subscripts in [this post](http://stackoverflow.com/questions/3543454/subscript-and-superscript-a-string-in-android), but if you want to apply that to the user's input as they're typing, that's gonna take a little more work. – Mike M. Jul 25 '16 at 13:38
  • yes , I want to do it with two textviews , one for subscript the other for superscript ... and there is also a buttton to add number . for example : Base : 2 power : 2 -----> Result : 2² . and user also should be able to do it times as he wants . bcz a formul has several subscripts and superscripts – Alireza Imani Jul 25 '16 at 13:48
  • Any help guys ? ;| – Alireza Imani Jul 26 '16 at 04:44
  • What's the problem, exactly? Sounds like you've got a plan. The post I linked shows multiple ways to display superscripts. What do you need help with? Where's your code, and what specific issues are you having in implementing this? – Mike M. Jul 26 '16 at 04:53
  • OMG !!!!!! no one can help me in this Forum :| – Alireza Imani Jul 26 '16 at 09:59
  • Chill out. Remember that the people here are volunteering their time. Anyway, remove the last `toString()` call, the one on `Html.fromHtml()`. And next time, don't post screenshots of code. Post all text as text. – Mike M. Jul 26 '16 at 10:09

1 Answers1

0

Try this as per your requirement

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="20dp">

    <TextView
        android:id="@+id/base_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:textColor="@android:color/black"
        android:textSize="20sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_toRightOf="@+id/base_value"
        android:gravity="top"
        android:text="n"
        android:textColor="@android:color/black"
        android:textSize="12sp" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:gravity="center"
    android:layout_margin="20dp">

    <TextView
        android:id="@+id/base_value_new"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="1"
        android:textColor="@android:color/black"
        android:textSize="20sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:layout_toRightOf="@+id/base_value_new"
        android:gravity="bottom"
        android:text="n"
        android:textColor="@android:color/black"
        android:textSize="12sp" />

</RelativeLayout>

Let us know if it does not work. If you need multiple of this layout try creating view at run time programmatically.

Dexto
  • 1,151
  • 9
  • 18