Android Question B4a Panel is similar to ? in Java/XML

Eric H

Active Member
Licensed User
Longtime User
I have been working in Java/XML to remake a project I originally did using B4a (Sleep Sound Mixer HQ). I am still learning Java/XML and am having difficulty remaking the interface in XML. The B4a version of my project used panels with rounded corners filled with a gradient and each panel contained several elements (TextView, Seekbar, ImageView, etc...). In doing some searching I was able to find that I could do a panel-like 'shape' filled with a gradient like this:

gradient.xml
B4X:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="90"
        android:startColor="#121212"
        android:endColor="#252525" />

    <stroke 
        android:width="1dp" 
        android:color="#000000" />
    <corners 
        android:radius="10dp" /> 

</shape>

activity_main.xml
B4X:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/app_title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textColor="#63a0B5"
        android:typeface="serif"
        android:text="@string/app_name"
        android:textSize="26sp" />

    <TextView
        android:id="@+id/app_dev_subtitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dip"
        android:gravity="center_horizontal"
        android:textStyle="italic"
        android:text="@string/dev_name_subtitle"
        android:textSize="14sp" />



    <ScrollView
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="#000000" >
   
       <LinearLayout
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical" >
   
           <View
               android:id="@+id/view_sound1"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound2"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound3"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound4"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound5"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound6"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound7"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound8"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound9"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound10"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound11"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound12"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound13"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound14"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound15"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound16"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound17"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound18"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
   
           <View
               android:id="@+id/view_sound19"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_sound20"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_custom_mix1"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_custom_mix2"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_custom_mix3"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_custom_mix4"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_custom_mix5"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_timer_settings"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_rate_app"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_more_apps"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_suggestions"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_bug_report"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
           
           <View
               android:id="@+id/view_sound_credits"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />
               <include layout="@layout/gradient"/>
           
       </LinearLayout>
   
    </ScrollView>

</LinearLayout>

The activity_main 'panel' was this code, which used the gradient.xml code as the background:
B4X:
<View
               android:id="@+id/view_sound12"
               android:layout_width="fill_parent"
               android:layout_height="85dip"
               android:background="@layout/gradient" />

So the main question- is there a semi-direct way to translate B4a panels into Java/XML? and the 2nd part of the question... am I on the right track for doing this? Any suggestions or links that might help?

Thanks so much folks :)

Eric H
 

DonManfred

Expert
Licensed User
Longtime User
i dont know

But i would suggest a panel must be something like
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:eek:rientation="vertical"

cause it must be something which can hold childviews...
 
Upvote 0
Top