android-custom-view

GridView is not Scrolling smoothly

扶醉桌前 提交于 2020-01-17 11:16:03
问题 I have 100 plus images present in drawable folder I am creating gallery in GridView, But facing scrolling issues. gridView is not scrolling smoothly although I have used ViewHolder... here is my code... public class MainActivity extends Activity { int[100] Names_images = {R.drawable.img1,R.drawable.img3,R.drawable.img4,R.drawable.img5,R.drawable.img6,...};//100 images String[100] names = {"name1","name2","name3","name4","name5","name6",...};// 100 names GridView gridview;

How to set a max height of a any kind of view?

泄露秘密 提交于 2020-01-16 19:18:53
问题 Background I'm trying to put a view within a container view, so that the container will allow the view to have any height (and/or width,depending on your specification) , yet not pass a specific one. The problem There is no way to define "maxHeight" for any kind of view. You can only use exact size , use some tricks to take the spare size (layout_weight) or make the scrollView take as much space as it needs. The only similar thing is for EditText , which you can use "maxLines" together with

Android - TextView's Weight Property in LinearLayout is being ignored when used as ListView row View

这一生的挚爱 提交于 2020-01-16 10:00:20
问题 I have a CustomListView, when I longClick on a row, the layout of that row changes to a different listRow Layout. So far, everything is working, however, the layout of the new view is compressed. Here are my xml files: search_result_layout.xml --> this is the original xml file used by the customListView Adapter. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/search_result_layout" android:layout_width="fill

ActionBar android with custom shape

女生的网名这么多〃 提交于 2020-01-16 00:46:16
问题 I have to develop an actionBar with a custom shape for an android app. The actionBar is a rectangle as always, but every option (icon) I add to the actionBar has to be bigger than the actionBar and with a circle shape. Any ideas how to implement that feature? I can't find how to solve this problem. Thanks. 回答1: I think you should remove the ActionBar completely and make your own custom view with desired content (as mentioned) and put that view on top of each activity. Customizing action bar

Crash on calligraphy library by chris Jenx for Android Q

≡放荡痞女 提交于 2020-01-14 09:10:32
问题 I have a calligraphy library I am using for custom fonts which seems to work on all versions except for android Q , where it crashes my app right on launch.Any one else has had to deal with the same issue lately? Here's my crash report : Caused by: android.view.InflateException: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Error inflating class android.support.v7.widget.FitWindowsLinearLayout Caused by:

Custom xml attribute to a @layout reference

荒凉一梦 提交于 2020-01-14 09:09:49
问题 I would like to make a custom view with own xml attributes. I would like to specify a header layout that will be inflated in my custom xml view, something like this: <com.example.MyCustomWidget android:layout_width="match_parent" android:layout_height="match_parent" app:headerLayout="@layout/my_header" /> Is that possible and how to i get the layout resource from TypedArray ? So at the end I would like to do something like this: class MyCustomWidget extends FrameLayout { public

Android: How to test a custom view?

牧云@^-^@ 提交于 2020-01-11 18:03:12
问题 There are several methods of unit testing in Android, what's the best one for testing a custom view I've written? I'm currently testing it as part of my activity in an instrumentation test case, but I'd rather test just the view, isolated. 回答1: Well unit testing is a method by which individual units of source code are tested to determine if they are fit for use. So when you say you want to test your custom view, you can check various methods of your custom views like "onTouchEvent", "onDown",

Android: Start the circular progress bar from top (270°)

 ̄綄美尐妖づ 提交于 2020-01-11 15:40:32
问题 I have defined a circular progress bar using the following drawable "ciruclar_progress_bar.xml" <?xml version="1.0" encoding="utf-8"?> <item android:id="@android:id/progress"> <shape android:innerRadiusRatio="2.5" android:shape="ring" android:thicknessRatio="25.0" > <gradient android:centerColor="@color/gray" android:endColor="@color/gray" android:startColor="@color/gray" android:type="sweep" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <shape android:innerRadiusRatio

canvas is offset by setting identity matrix in onDraw of custom view

人走茶凉 提交于 2020-01-11 07:18:34
问题 I set a matrix to my canvas in the onDraw method of a custom view via canvas.setMatrix(matrix); then I just draw a grid using predefined paints: canvas.drawRect(0,0,viewWidth,viewHeight, background); for(int i=0; i <= nRows; i++){ canvas.drawLine(0,i*cellHeight, nCols*cellWidth,i*cellHeight,lines); canvas.drawLine(i*cellWidth, 0, i*cellWidth, nRows*cellHeight, lines); if(i != nRows) canvas.drawText(""+i, i*cellWidth, (i+1)*cellHeight, text); } and for some reason the whole canvas is offset by

SherlockActionBar: How to adjust CustomView against actionBar

此生再无相见时 提交于 2020-01-09 19:04:48
问题 Question: How can I have the title back? Here's the screenshot (Missing title): Actionbar setting: ActionBar actionBar = getSupportActionBar(); actionBar.setTitle("My Title"); actionBar.setIcon(drawable.dropdown_user); View mLogoView = LayoutInflater.from(this).inflate(R.layout.mLogoView, null); actionBar.setCustomView(mLogoView); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); mLogoView.xml: <?xml version="1