Here is my code so far using FragmentTabHost; the problem is that the height is not dynamically changing (300dp) not compatible for bigger screens
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="300dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Counter counter 10:00:00"
android:textColor="#color/red"
android:textStyle="bold"/>
</LinearLayout>
<RelativeLayout
style="#style/MyActionBar"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_weight="2"
android:background="#color/darkactionb"
android:gravity="bottom" >
<ImageView
android:id="#+id/action_bar_addtarget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="#string/Login"
android:cropToPadding="true"
android:gravity="bottom"
android:padding="#dimen/abc_action_bar_icon_vertical_padding_material"
android:scaleType="fitStart"
android:src="#drawable/custom_actionbar_icon_bottom_call_target"
android:visibility="visible" />
<ImageView
android:id="#+id/action_bar_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:adjustViewBounds="false"
android:contentDescription="#string/Login"
android:onClick="showCallResult"
android:padding="#dimen/abc_action_bar_icon_vertical_padding_material"
android:src="#drawable/custom_actionbar_icon_bottom_edit_callresult"
android:visibility="visible" />
<ImageView
android:id="#+id/action_bar_autodial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/Login"
android:onClick="showDialpad"
android:padding="#dimen/abc_action_bar_icon_vertical_padding_material"
android:scaleType="center"
android:src="#drawable/custom_actionbar_icon_bottom_home_list"
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
Is the problem that wrap_content not working and when text/images size chenged tabs not enlarged?
if yes:
Don't know why it don't apply xml settings, but it looks ok if sets up it progrommatically, for example:
... some code that defines an add tabs to code FragmentTabHost ...
for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) {
LinearLayout.LayoutParams params
= new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
params.weight = 50;
tabhost.getTabWidget().getChildAt(i).setLayoutParams(params);
}
Hope this helps.
Related
I have two LinearLayout like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#drawable/border"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2"
android:onClick="viewTipsDetail">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:src="#mipmap/img_breakfast" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Đừng bỏ bữa sáng"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="Các nghiên cứu cho thấy bữa sáng là một những điê"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#drawable/border"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="2"
android:onClick="viewTipsDetail">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:src="#mipmap/img_waterglass" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Uống đủ nước"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity=""
android:singleLine="false"
android:text="Bổ sung đủ nước cho cơ thể, ngay cả các bạn làm việc trong môi trường máy lạnh hoặc ngoài trời. Việc mất nước có thể khiến bạn căng thẳng, khó tập trung vào công việc"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
I'm going to plan implement an onClickEvent with same method for both of them. In this occasion, the event will call viewTipsDetail() method. So how can I get the image src, the text in specific LinearLayout with only one method? And is there any possible way to auto-generate a LinearLayout like this with given detail?
This is sample, I'm going to use more LinearLayout than this, so what I need in general is a possible method for getting detail in specific LinearLayout.
<LinearLayout
id="#+id/layout1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
onClick="onLayoutClick"
android:orientation="vertical">
<LinearLayout
id="#+id/layout2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
onClick="onLayoutClick"
android:orientation="vertical">
In code:
#Override
public void onLayoutClick(View view) {
// click click
// view.getTag()
}
Or just use list view for achieve that...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have some problem ListView in ScrollView not displaying all items
and I try this code, it works but it takes a long time to process in the Adapter.
I have tried this code which is faster but doesn't display all items
How do I fix it?
Note: my ListView id is lv_poll_feed
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
android:background="#color/color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lay_edit_comment"
android:scrollbars="none">
<RelativeLayout
android:id="#+id/lay_big"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/lay_body_timeline_detail_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view_line_4">
<TextView
android:id="#+id/tx_time_timeline_detail_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:padding="10dp"
android:text="-"
android:textColor="#color/color_gray_light"
android:textSize="#dimen/tx_size_smally_time"/>
<RelativeLayout
android:id="#+id/lay_profile_detail_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_time_timeline_detail_user"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp">
<TextView
android:id="#+id/tx_timeline_detail_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="10dp"
android:text="-"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_small"/>
<RelativeLayout
android:id="#+id/lay_center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_timeline_detail_detail"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tx_catego_topic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="#drawable/bg_button"
android:padding="5dp"
android:text="xxxxxxx"
android:textColor="#color/color_white"
android:textSize="#dimen/tx_size_small"
android:visibility="gone"/>
<com.cunoraz.tagview.TagView xmlns:tagview="http://schemas.android.com/apk/res-auto"
android:id="#+id/tagCloudLinkView_topic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
tagview:lineMargin="5dp"
tagview:tagMargin="5dp"
tagview:theme="#style/AppTheme"/>
<ListView
android:id="#+id/lv_poll_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:divider="#null"
android:visibility="visible">
</ListView>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/img_timeline_profile_detail_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_timeline_detail_detail"
android:adjustViewBounds="true"
android:visibility="visible"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/lay_timeline_detail_emoji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lay_profile_detail_detail"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="10dp">
<LinearLayout
android:id="#+id/lay_big_emoji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="3">
<LinearLayout
android:id="#+id/lay_emoji1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/amazed_1"/>
<TextView
android:id="#+id/tx_number_emoji_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/funny_2"/>
<TextView
android:id="#+id/tx_number_emoji_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/love_3"/>
<TextView
android:id="#+id/tx_number_emoji_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/sorrow_2"/>
<TextView
android:id="#+id/tx_number_emoji_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/anger_5"/>
<TextView
android:id="#+id/tx_number_emoji_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_emoji6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/horrified_6"/>
<TextView
android:id="#+id/tx_number_emoji_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textSize="#dimen/tx_size_smally_time"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/view_line_5"
android:layout_below="#+id/lay_timeline_detail_emoji"
android:layout_marginTop="5dp"
android:background="#color/text_bottombar"/>
<RelativeLayout
android:id="#+id/lay_body_quest_topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view_line_5"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<LinearLayout
android:id="#+id/lay_timeline_detail_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/img_up"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/up_1"/>
<TextView
android:id="#+id/tx_timeline_detail_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_up"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" 53"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_timeline_detail_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/img_comment"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/comment_1"/>
<TextView
android:id="#+id/tx_timeline_detail_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_comment"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" 53"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_profile_detail_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/share_1"/>
<TextView
android:id="#+id/tx_timeline_detail_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="#string/tx_share"
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
<TextView
android:id="#+id/tx_timeline_detail_number_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" "
android:textColor="#color/tx_color_token"
android:textSize="#dimen/tx_size_smally"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/view_line_3"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_below="#+id/lay_body_quest_topic"
android:layout_marginTop="5dp"
android:background="#color/bottombar"/>
<RelativeLayout
android:id="#+id/lay_timeline_detail_select_emoji_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/lay_body_quest_topic"
android:layout_marginBottom="-10dp"
android:background="#drawable/bg_emoji"
android:visibility="gone">
<LinearLayout
android:id="#+id/lay_star"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tx_name_detail"
android:gravity="center"
android:orientation="horizontal">
<RadioGroup
android:id="#+id/radioGroupQuest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="0dp">
<RadioButton
android:id="#+id/emoji1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#drawable/img_emoji_amazed"
android:button="#android:color/transparent"
android:checked="false"
android:gravity="center"/>
<RadioButton
android:id="#+id/emoji2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#drawable/img_emoji_funny"
android:button="#android:color/transparent"
android:checked="false"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
You should not add same direction scrolling layout inside another scrolling layout. Result will not always intended. Here your listview is wrapping to single element of your ListView because you have added it inside Scrollview. You should not do that in first place but if you can't change your layout then do the following changes:
Change ListView to RecyclerView and change the adapter accordingly.
Also, change ScrollView to NestedScrollView.
You can use this function :
public static void setListViewHeight(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
and set like this :
ListView list = (ListView) view.findViewById(R.id.listview);
setListViewHeight(list);
Helo,
my code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1.0"
>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:padding="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3sp"
android:background="#color/colorAccent"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
>
<TextView
android:id="#+id/textView32"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/accounts"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10sp"
android:background="#color/colorAccent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_Account_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_description"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold"
/>
</TableRow>
</TableLayout>
<!-- Scrollable Area 1 Begin -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorAccent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<!-- Scrollable Area 1 End -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent"
android:orientation="horizontal">
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto hinzufügen" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center|bottom"
android:paddingBottom="10sp"
android:paddingLeft="20sp"
android:paddingRight="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent2"
android:orientation="vertical"
android:gravity="center|bottom">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="3sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/account_input_output"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_IO_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_date"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Nr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_description"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Ausgabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_ausgabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Eingabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_eingabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent2"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:orientation="horizontal">
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion hinzufügen"
/>
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
My problem is:
The two buttons button6 and button7 below aren't displayed on screen. On android studio they are, but not on my mobile phone.
What am I doing wrong?
This is displayed in android studio gui builder
This is display on android emulator or real device
Hmm... I don't know if it's the best solution.
But I set the bottom padding of the second linear layout to:
20sp + 20 sp + black stripe on the bottom sp + 20 sp
Context context = rootView.getContext();
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
int width = resources.getDimensionPixelSize(resourceId);
LinearLayout l = (LinearLayout)rootView.findViewById(R.id.scrollView2);
float density = context.getResources().getDisplayMetrics().density;
int paddingDp = (int)(20 * density);
l.setPadding(paddingDp, 0, paddingDp, paddingDp + paddingDp + width);
I'm having a strange trouble and didn't find any solutions on the web.
I'm adding a TextView dynamically into a RelativeLayout, with custom fonts, and sometimes the text appears underlined.
public void bouton_valide_ajout_texte(View v)
{
new_text_view.setText(((TextView) dialog.findViewById(R.id.edit_ajoute_texte)).getText());
RelativeLayout rl_newtext_1 = (RelativeLayout)findViewById(R.id.rl_newtext_1);
rl_newtext_1.addView(new_text_view);*/
TextView text_view = new TextView(this);
text_view.setText(((TextView) dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText());
ListView liste_view_police = (ListView) dialog_ajoute_texte.findViewById(R.id.list_view_dialog_polices);
text_view.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
text_view.setTypeface(listePolices.get_typeface(position_item_police));
text_view.setTextColor(Color.argb(255, 0, 0, 0));
text_view.clearComposingText();
container_calques.addView(text_view);
Object[] tab_calque = new Object[5];
tab_calque[0]="texte";
tab_calque[1]=text_view;
tab_calque[2]=12;
tab_calque[3]=0;
liste_calques.add(tab_calque);
calque_selectionne=liste_calques.size()-1;
text_view.setOnTouchListener(new TouchListener_calque(liste_calques.size()-1));
dialog_ajoute_texte.hide();
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ebm="http://schemas.android.com/apk/res-auto"
xmlns:sat="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="350dp"
android:layout_gravity="center"
android:id="#+id/rl_container_tshirt">
<ImageView
android:id="#+id/tshirt_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/tee_shirt_blanc">
</ImageView>
<RelativeLayout
android:id="#+id/container_calques"
android:layout_width="120dp"
android:layout_height="220dp"
android:layout_marginLeft="88dp"
android:layout_marginTop="85dp"
>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/layout_reglages_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
>
<SeekBar
android:id="#+id/seekbar_taille"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:max="40"
android:progress="20"
/>
<SeekBar
android:id="#+id/seekbar_rotation"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="50dp"
android:layout_alignParentLeft="true"
android:max="360"
android:progress="180"
/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Supprimer"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:onClick="bouton_supprimer_calque"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Couleur"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:layout_marginTop="40dp"
android:onClick="bouton_choisir_couleur"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Police"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:layout_marginTop="80dp"
android:onClick="bouton_choisir_police"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="ajouter texte"
android:id="#+id/ajouter_calque"
android:onClick="bouton_ajoute_texte"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="ajouter image"
android:id="#+id/ajouter_image"
android:onClick="bouton_ajoute_image"
android:layout_alignParentRight="true"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="enregistrer création dans galerie"
android:id="#+id/enregistrer_creation"
android:onClick="bouton_enregistrer_creation"
android:layout_below="#+id/ajouter_calque"
/>
</RelativeLayout>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.view.ext.SatelliteMenu
android:id="#+id/menu_flottant_gauche"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_margin="8dp"
sat:satelliteDistance="170dp"
sat:mainImage="#drawable/ic_launcher"
sat:totalSpacingDegree="90"
sat:closeOnClick="true"
sat:expandDuration="200"
/>
</FrameLayout>
</LinearLayout>
Solved
I replaced
text_view.setText(((TextView);
dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText());
By
text_view.setText(((EditText);
dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText().toString());
The possible underline could by the ListView as it puts a divider between its items. Look at this answer to get rid of the divider
Please make sure you don't have any inputType to your textview as follows
android:inputType="something"
I am trying to find a way to animate changing the alpha of a FrameLayout's foreground drawable, but i cant seem to find a way of doing it.
If someone could point me in the right direction as to how i should go about this i would be hugely grateful.
The relevant code is below:
XML layout file:
<com.bacon.corey.audiotimeshift.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="0dp"
sothree:shadowHeight="10dp"
sothree:paralaxOffset="100dp"
sothree:fadeColor="#android:color/transparent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:id="#+id/recordingListMainLayout"
android:foreground="#drawable/dim_shadow_shape_dark"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainLayoutContainer"/>
<!--
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:padding="0dp"
android:layout_margin="0dp"
/>
-->
</LinearLayout>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionsMenu
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:gravity="right"
app:fab_addButtonColorNormal="#color/holo_red_light"
app:fab_addButtonColorPressed="#color/c16"
app:fab_addButtonPlusIconColor="#color/white"
app:fab_expandDirection="up"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c15"
app:fab_colorPressed="#color/c15"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c8"
app:fab_colorPressed="#color/c8"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a1"
app:fab_colorPressed="#color/a1"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a2"
app:fab_colorPressed="#color/a2"
app:fab_size="mini"
/>
</LinearLayout> </com.bacon.corey.audiotimeshift.FloatingActionsMenu>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:textSize="16sp"
android:id="#+id/slideUpPanel"
>
</FrameLayout>
</com.bacon.corey.audiotimeshift.SlidingUpPanelLayout>
And the java code that i use to change the alpha of the foreground:
fabMain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
boolean expanded = fabMenu.toggle();
mainActivity.getDimShadowDrop().setForeground(getResources().getDrawable(R.drawable.dim_shadow_shape_light));
mainActivity.getDimShadowDrop().getForeground().setAlpha(180);
if (expanded){
((MainActivity)getActivity()).replaceFragment(new RecordFragment(), R.id.slideUpPanel, false);
slidingUpPanelLayout.expandPanel();
defaultColor = getResources().getColor(R.color.recordDefaultColor);
}
}
});
Instead of the typical way you do it with an Animation which is from 0 to 1 you use 0 to 255. Something like this will pulse the Foreground of a CardView.
public static void pulseForeground(CardView view, long duration) {
ObjectAnimator animator = ObjectAnimator.ofInt(view.getForeground(), "alpha", 0, 255);
animator.setDuration(duration);
animator.setStartDelay(20);
animator.setRepeatMode(Animation.REVERSE);
animator.setRepeatCount(Animation.INFINITE);
animator.start();
}