I have a listview in my dialog and then I have to use the header layout and footer layout. the way I am doing it , aligning my header layout to top and the footer layout to bottom . but it has a problem. take a look at below picture ..
But by doing that the dialog gets Longer in size which is not expected
I am traped in this situation. Well If i align my footer with the listview end then the footer gets out of the screen. which is also not expected.
What I want :
I want that My listview should be visible in the center of dialog with the header layout align top and the footer layout align to the bootm of the dialog botttom border and it should not take the full length of the screen.
Isnt there a way to align the footer to the bottom of the dialog and dialog it self maintain its height (Note: I do not want to give the dialog hard coded height as I want the dialog to be look same on all devices. )
Please help I am stuck in the situation. If we look at the google dialog whcih comes while installing the app, it has short dialog with the listview in center of it and buttons are aligning to bottom of the dialog. How they are doing it?
Here's the dynamic solution for your problem..
Sample dialog xml file name activity_list_test.xml..
<?xml version="1.0" encoding="utf-8"?><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:background="#color/page_bg"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Header Button" />
<ListView
android:id="#+id/lvCommon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bottom Button" /></LinearLayout>`
Here's the calling from a fragment/activity where you want..
private void showAlert() {
AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
View view = LayoutInflater.from(getActivity()).inflate(R.layout.activity_list_test, null);
dialog.setView(view);
dialog.setTitle(null);
dialog.setMessage(null);
ArrayList<String> mList = new ArrayList<>();
for (int i = 0; i < 15; i++) {
mList.add("ABC");
}
ListView lvCommon = (ListView) view.findViewById(R.id.lvCommon);
int deviceHeight = getScreenSize(getActivity()).y;
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, deviceHeight / 3,1f);
lvCommon.setLayoutParams(layoutParams);
lvCommon.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, mList));
dialog.setCancelable(false);
dialog.show();
}
There device height will be auto measure and according to it the dialog size will be "deviceheight/3"..so it will be maintain in all devices..
Now you need the method getScreenSize..So here's it is::
public static Point getScreenSize(Activity act) {
int screenWidth = 0;
int screenHeight = 0;
final DisplayMetrics metrics = new DisplayMetrics();
act.getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenWidth = metrics.widthPixels;
screenHeight = metrics.heightPixels;
return new Point(screenWidth, screenHeight);
}
You can set layout to your Dialog like below way
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="#+id/header_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Header Text"
android:gravity="center|top"/>
<ListView android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center_vertical/>
<TextView android:id="#+id/footer_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Footer Text"
android:gravity="center|bottom"/>
</LinearLayout>
It will set Header View to Top,ListView to Center and Footer View to Bottom
You can try this one,.. create one xml and copy paste this code and set your dialog xml
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:gravity="center"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/table_rl"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:orientation="vertical">
<TextView
android:id="#+id/your_items_tv"
android:textColor="#color/text_black"
customFontPath="lato_black.ttf"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="20dp"
android:text="HEADING"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_below="#+id/your_items_tv"
android:paddingBottom="5dp"
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textColor="#color/text_black"
customFontPath="lato_bold.ttf"
android:layout_gravity="center"
android:gravity="left"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="TOP BAR"/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_below="#+id/table_rl"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff">
<TextView
android:padding="5dp"
android:textSize="18dp"
android:textColor="#color/text_black"
customFontPath="lato_bold.ttf"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Bottom Bar "/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Related
I have the following Horizontal Linear Layout inside a Vertical Linear Layout :
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#color/White"
android:orientation="vertical">
<TextView
android:id="#+id/pokemonTeambuilderTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|start"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingEnd="10dp"
android:paddingBottom="5dp"
android:text="#string/placeholder"
android:textColor="#color/Black"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/pokemonTeambuilderSpritesLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
And programmatically I set the elements this way in my adapter :
for (Pokemon pokemon : pokemonTeam.getPokemonList()) {
String pokemonNickname = pokemon.getNickname();
String pokemonName = pokemon.getName();
ImageView tvPokemonSprite = new ImageView(mContext);
int color = PokemonUtils.getDominantColorFromPokemon(pokemon.get_id(),mContext);
tvPokemonSprite.setImageResource(PokemonUtils.getPokemonSugimoriImageById(pokemon.get_id(), mContext));
tvPokemonSprite.setScaleType(ImageView.ScaleType.FIT_CENTER);
PokemonUtils.setResourceAndBorderBackgroundColorToElementFromColor(tvPokemonSprite,R.drawable.circle_shape,color,PokemonUtils.lighterColor(color, DARK_FACTOR));
TableLayout.LayoutParams layout = new TableLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
tvPokemonSprite.setLayoutParams(layout);
holder.teamSpritesLinearLayout.addView(tvPokemonSprite);
}
However , if I rotate my phone , the elements don't fit completly in the Linear Layout , the bottom and the top is half cutted , also if the horizontal linear layout only have 1 Pokemon , instead of adapting to 1 slot it expands the WHOLE view (as you can see with charizard)
Add below code to imageview:
tvPokemonSprite.setAdjustViewBounds(true)
i hope work for you.
I have a problem with this specific dialog, I implemented it as an option to be shown in the Options Menu in my toolbar but it doesn't show the dialog's contents when I clicked on the option. I have tried these with other dialog layouts I have implemented and all of them work when I implemented them here so I have a hunch that the problem is with the XML layout but I can't seem to find the problem.
Code:
else if(id == R.id.action_setting)
{
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog_settings);
dialog.setTitle("Settings");
CheckBox set_splash = dialog.findViewById(R.id.setting_check);
boolean have_splash =pref.getBoolean(SplashActivity.HAVE_SPLASH,false);
if(have_splash)
set_splash.setChecked(true);
else
set_splash.setChecked(false);
ImageButton confirm_btn = dialog.findViewById(R.id.setting_confirm);
ImageButton cancel_btn = dialog.findViewById(R.id.setting_cancel);
confirm_btn.setOnClickListener(v -> {
boolean new_splash = set_splash.isChecked();
edit.putBoolean(SplashActivity.HAVE_SPLASH,new_splash);
edit.commit();
dialog.dismiss();
});
cancel_btn.setOnClickListener(v -> dialog.dismiss());
dialog.show();
}
XML :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout5">
<ImageButton
android:id="#+id/setting_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/button_highlight_dark"
android:paddingVertical="20dp"
app:srcCompat="#drawable/ic_confirm" />
<ImageButton
android:id="#+id/setting_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/button_highlight_dark"
android:paddingVertical="20dp"
app:srcCompat="#drawable/ic_cancel" />
</LinearLayout>
<TextView
android:id="#+id/setting_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/themeDark"
android:paddingVertical="10dp"
android:paddingLeft="10dp"
android:text="#string/settings"
android:textColor="#color/white"
android:textSize="10pt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/themeLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/setting_text">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6"
android:textColor="#color/white"
android:paddingVertical="20dp"
android:paddingLeft="10dp"
android:text="#string/splash_setting"
android:textSize="10pt" />
<CheckBox
android:id="#+id/setting_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
The match_parent parameters in your dialog are ignored. Therefore, the dialog has a width of 0.
The easiest way to get the correct height and width, is by using an AlertDialog.Builder.
If a customized AlertDialog isn't enough, you can make the dialog full size by following this answer:
Android get full width for custom Dialog
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog_settings);
Window window = dialog.getWindow();
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
I am using a HorizontalScrollView to slide TextViews over the screen . My question now is, if there is any way to make the width of each RelativeLayout match the width of the phone screen, independent of the phone the user uses.
So is there a way to like get the display width of the device and then set it as the width of my RelativeLayout? Or is there even a better way to do it?
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#android:color/holo_blue_dark">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="15sp"
android:textColor="#android:color/black"
android:id="#+id/info"
android:layout_margin="5dp"
android:textAlignment="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/info"
android:text="0"
android:textSize="80dp"
android:layout_centerHorizontal="true"
android:id="#+id/getrunkeneLiter"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#android:color/holo_green_light">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#android:color/black"
android:layout_margin="5dp"
android:id="#+id/danke"
android:textAlignment="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Feedback verfassen"
android:onClick="feedback"
android:layout_below="#+id/danke"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
You can get the screen size and set it to each of your views programmatically. Alternatively, you can use a weighted LinearLayout and set its size to number of elements times screen size.
You can use this function to get the screen size (and then use the x value of the Point):
public static Point getScreenSize(Context context) {
final Point size = new Point();
final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final Display display = wm.getDefaultDisplay();
display.getSize(size);
return size;
}
To update the relative layouts you need to add an id to each of them. For example:
<RelativeLayout
android:id="#+id/first_subview"
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#android:color/holo_blue_dark">
And then in your activity:
private void updateViews() {
Point screenSize = getScreenSize(this);
updateView(findViewById(R.id.first_subview), screenSize);
updateView(findViewById(R.id.second_subview), screenSize);
...
}
private void updateView(View view, Point screenSize) {
view.getLayoutParams().width = screenSize.x
}
In my chat application I have a layout with a listview (a chat between two users) and an edittext input for writing a new message for the same conversation.
The first problem happens when a user clicks on input - a soft keyboard pops up but the listview remains at the same position as before, instead of jumping up along with an edittext input and keeping the same interval between.
The second problem is when I dismiss keyboard and return to the default state with a large number of lines, the listview again remains at the same position and the edittext overlaps it.
My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/main_bg"
android:gravity="right"
android:orientation="vertical" >
<include
android:layout_alignParentTop="true"
layout="#layout/actionbar_layout" />
<ListView
android:id="#+id/lsvMessage"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="0dp"
android:layout_marginTop="50dp"
android:background="#color/_transperant"
android:divider="#null"
android:dividerHeight="0dp">
</ListView>
<LinearLayout
android:id="#+id/txtMsgLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:background="#color/_transperant">
<EditText
android:id="#+id/txtMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:ems="10"
android:hint="#string/btn_ask_hint"
android:background="#drawable/edit_text_style"
android:textColor="#color/_white"
android:singleLine="true"
android:textAlignment="viewStart"
android:inputType="textMultiLine|textCapSentences|textNoSuggestions"
android:layout_weight="1">
</EditText>
<RelativeLayout
android:id="#+id/message_spinner_layout"
style="#style/layout_fill_width"
android:gravity="right"
android:layout_weight="0">
<Spinner
android:id="#+id/message_lng_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:gravity="right"
android:paddingLeft="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:background="#drawable/spinner_setting"
android:layout_alignBottom="#id/message_lng_spinner"
android:layout_marginBottom="12dp"
android:layout_marginRight="20dp" />
</RelativeLayout>
<Button
android:id="#+id/btnSend"
style="#style/submit_button_style"
android:text="#string/btnSend"
android:background="#drawable/submit_button"
android:layout_weight="0"/>
</LinearLayout>
</RelativeLayout>
I tried to fix it programmatically and count the high of edittext layout to move listview accordingly but it didn't work.
final View activityRootView =
((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
final View msgLayout = (ViewGroup)findViewById(R.id.txtMsgLayout);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener
(new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
Rect r = new Rect();
activityRootView.getWindowVisibleDisplayFrame(r);
int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 100) {
scrollMyListViewToBottom();
} else {
int heighListview = msgLayout.getHeight();
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)
lsvMessage.getLayoutParams();
params.setMargins(0,50,0,heighListview);
lsvMessage.setLayoutParams(params);
}
}
});
Can I fix it with a properly marked up layout or code behind?
I had same problem. I have tried all answers in the stackoverflow, but not have any final solution.
I found solution from google native message app:
ComposeMessageActivity layout
ComposeMessageActivity here have a method: "smoothScrollToEnd"
and there are have a MessageListView.java class for detect onSizeChanged.
Good day.
I have an android application. In my application, I have a custom listView with 5 columns that are textViews. The user can click the rows, once he does, the row layout will change, changing the last 2 textViews to EditTexts. I then register the new EditTexts onto my custom keyboard taken from this example - kindly note that I did a functional copy-paste of his example with regards to the custom keyboard class and how to make it work in the main layout. However, when I click the EditText in the row, my custom keyboard does not show up at all.
I have a global variable as such:
CustomKeyboard mCustomKeyboard;
And in my onCreate() method in the activity, I do:
mCustomKeyboard= new CustomKeyboard(this, R.id.keyboardview, R.xml.custom_keyboard);
This is my layout, I have the KeyboardView at the bottom of the Layout:
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".SearchResult" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- A lot of views go here, enclosed in my linear layout -->
</LinearLayout>
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone" />
</RelativeLayout>
Here is the code that changes the layout. What I do is that I take the row values from the old layout, get the new layout search_result_inflate, then set the texts of the new layout using the values I got. Kindly note the mCustomKeyboard.registerEditText(R.id.qtyInputSearchResult); line after inflating the layout:
private void changeLayout(final View view){
//get views from old layout
TextView textViewQuantity = (TextView)view.findViewById(R.id.qtyInput);
TextView textViewDiscountReq = (TextView)view.findViewById(R.id.discInput);
TextView textViewName = (TextView)view.findViewById(R.id.dialogItemName);
TextView textViewPrice = (TextView)view.findViewById(R.id.price);
TextView textViewDiscount = (TextView)view.findViewById(R.id.discount);
//store values in strings
String itemName = textViewName.getText().toString();
String itemPrice = textViewPrice.getText().toString();
String itemDiscount = textViewDiscount.getText().toString();
String itemQty = textViewQuantity.getText().toString();
String itemDisc = textViewDiscountReq.getText().toString();
//set the view to gone
textViewQuantity.setVisibility(View.GONE);
textViewDiscountReq.setVisibility(View.GONE);
textViewName.setVisibility(View.GONE);
textViewPrice.setVisibility(View.GONE);
textViewDiscount.setVisibility(View.GONE);
//get the old layout
LinearLayout ll_inflate = (LinearLayout)view.findViewById(R.id.search_result_layout);
//get the inflate/new view
View child = getLayoutInflater().inflate(R.layout.search_result_inflate, null);
//get the views in the new view, populate them
TextView newName = (TextView)child.findViewById(R.id.dialogItemName);
newName.setText(itemName);
TextView newDiscount = (TextView)child.findViewById(R.id.discount);
newDiscount.setText(itemDiscount);
TextView newPrice = (TextView)child.findViewById(R.id.price);
newPrice.setText(itemPrice);
EditText qtyInput = (EditText)child.findViewById(R.id.qtyInputSearchResult);
qtyInput.setText(itemQty);
EditText discInput = (EditText)child.findViewById(R.id.discInputSearchResult);
discInput.setText(itemDisc);
//show new layout
ll_inflate.removeAllViews();
ll_inflate.removeAllViewsInLayout();
ll_inflate.addView(child);
mCustomKeyboard.registerEditText(R.id.qtyInputSearchResult);
}
Here is my search_result_inflate.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/search_result_inflate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:minHeight="50dp"
android:orientation="horizontal"
android:padding="1dip"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:padding="1dip" >
<TextView
android:id="#+id/dialogItemName"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="0.54"
android:gravity="center"
android:text="Item Name"
android:textSize="23sp" />
<TextView
android:id="#+id/price"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="0.14"
android:gravity="center"
android:text="Price"
android:textSize="23sp" />
<TextView
android:id="#+id/discount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="0.10"
android:gravity="center"
android:text="Discount"
android:textSize="23sp" />
<EditText
android:id="#+id/qtyInputSearchResult"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="0.14"
android:background="#layout/edittext_selector"
android:gravity="center"
android:hint="qtyInput"
android:textColorHighlight="#color/white_opaque"
android:textSize="23sp" >
</EditText>
<EditText
android:id="#+id/discInputSearchResult"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.11"
android:background="#layout/edittext_selector"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:hint="discInput"
android:textColorHighlight="#color/white_opaque"
android:textSize="23sp" />
</LinearLayout>
</LinearLayout>
As you can see, I have 2 editTexts and I registered qtyInputSearchResult to the custom keyboard class. However, the custom keyboard does not show up.
I also tried to use the custom keyboard class on an editText in another activity and it works just fine. Am I missing something here? I'm confused as to why the custom keyboard does not show up properly.
Any help is very much appreciated, thank you.
Got it, I placed the keyboard layout in the search_result_inflate.xml like so:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/search_result_inflate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:minHeight="50dp"
android:orientation="horizontal"
android:padding="1dip"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:padding="1dip" >
<!-- a lot of components here -->
</LinearLayout>
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone" />
</RelativeLayout>