Skip to main content

Home/ Android Dev/ Group items tagged layout

Rss Feed Group items tagged

Kiran Kuppa

A Visual Guide to Relative Layouts In Android » Mark Lapasa - 0 views

  •  
    " I will walk through the 4 kinds of Relative Layout use cases. 1.Target view position in relation to parenting View Group (i.e. a layout container) 2.Target view alignment in relation to parenting View Group 3.Target view position in relation to another View 4.Target view alignment in relation to another View We'll use Jack and Jill buttons to demonstrate this. The first two categories are in relation to a parent layout (Jack and the parent view group). The last two categories show laying out in relation to another View (i.e. Jack + Jill)"
Kiran Kuppa

Android Layout Tricks #3: Optimize by merging - 1 views

  •  
    The was created for the purpose of optimizing Android layouts by reducing the number of levels in view trees.When the LayoutInflater encounters this tag, it skips it and adds the children to the parent.You can also use when you create a custom composite view. 
Kiran Kuppa

New Layout Widgets: Space and GridLayout - 0 views

  •  
    "Ice Cream Sandwich (ICS) sports two new widgets that have been designed to support the richer user interfaces made possible by larger displays: Space and GridLayout."
Kiran Kuppa

How to Position Views Properly in Layouts | Think Android - 0 views

  •  
    "First off, the difference between android:gravity and android:layout_gravity is that android:gravity positions the contents of that view (i.e. what's inside the view), whereas android:layout_gravity positions the view with respect to its parent (i.e. what the view is contained in). "
Vincent Tsao

How to disable a button on an appwidget? | Hello Android - 0 views

  • RemoteViews can't manipulate a buttons enabled/disabled state, but it can modify its visibility. So the trick is to have two buttons, the real one, and an other which is designed to look like the real one in disabled state, and change witch one is visible.
  • <Button android:id="@+id/startbutton" android:text="Start" android:visibility="visible"></Button> <Button android:id="@+id/startbutton_disabled" android:text="Start" android:clickable="false" android:textColor="#999999" android:visibility="gone"></Button>   <Button android:id="@+id/stopbutton" android:text="Stop"  android:visibility="gone"></Button> <Button android:id="@+id/stopbutton_disabled" android:text="Stop" android:clickable="false" android:textColor="#999999" android:visibility="visible"></Button>
  • RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget); remoteView.setViewVisibility(R.id.startbutton, View.GONE); remoteView.setViewVisibility(R.id.startbutton_disabled, View.VISIBLE); remoteView.setViewVisibility(R.id.stopbutton, View.VISIBLE); remoteView.setViewVisibility(R.id.stopbutton_disabled, View.GONE); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteView);
  • ...1 more annotation...
  • RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget); remoteView.setViewVisibility(R.id.startbutton, View.VISIBLE); remoteView.setViewVisibility(R.id.startbutton_disabled, View.GONE); remoteView.setViewVisibility(R.id.stopbutton, View.GONE); remoteView.setViewVisibility(R.id.stopbutton_disabled, View.VISIBLE); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteView);
Vincent Tsao

Help getting array from arrays.xml file (Android, Eclipse) - Stack Overflow - 0 views

  • I am just trying to display a list from an array that I have in my arrays.xml.
  • String[] testArray = getResources().getStringArray(R.array.testArray); /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState)
  • You can't initialize your testArray field this way, because the application resources still aren't ready.
  • ...1 more annotation...
  • protected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    // Create an ArrayAdapter that will contain all list items    ArrayAdapter<String> adapter;    mTestArray =  = getResources().getStringArray(R.array.testArray);        /* Assign the name array to that adapter and     also choose a simple layout for the list items */     adapter = new ArrayAdapter<String>(    this,    android.R.layout.simple_list_item_1,    mTestArray);    // Assign the adapter to this ListActivity    setListAdapter(adapter);    }}
Vincent Tsao

Binding to Data with AdapterView | Android Developers - 0 views

  • Spinner s2 = (Spinner) findViewById(R.id.spinner2);Cursor cur = managedQuery(People.CONTENT_URI, PROJECTION, null, null);     SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this,    android.R.layout.simple_spinner_item, // Use a template                                          // that displays a                                          // text view    cur, // Give the cursor to the list adatper    new String[] {People.NAME}, // Map the NAME column in the                                         // people database to...    new int[] {android.R.id.text1}); // The "text1" view defined in                                     // the XML template                                         adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);s2.setAdapter(adapter2);
Vincent Tsao

[Tip][Google I/O 2011]Apply A/B testing to your Android App - 5 views

private static final boolean isA = UUID.randomUUID().getLeastSignificantBits() % 2 == 0; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); if(isA){ setConte...

android tip

started by Vincent Tsao on 12 May 11 no follow-up yet
Simon Pan

Common Layout Objects | Android Developers - 1 views

    • Simon Pan
       
      1.每個LinearLayout裡的元件都能設定Weight 2.先量出有幾個元件 3.把沒有Weight(不用擴展)的元件先占據出位置 4.剩下有設Weight的元件才會依比例分配要占據多大。
  • rest equally
  • gravity, by default, is left
  • ...8 more annotations...
  • topmost or leftmost
  • A table can leave cells empty, but cells cannot span columns
  • a single row
  • specified by ID
  • order given
  • toLeftOf
  • android:padding="10px"
  • all hold child UI elements
Vincent Tsao

请教,使用layout_gravity属性不能垂直居中 - China Android Dev | Google Groups - 0 views

  • 按我理解,layout_gravity 属性是用于设置View 与其容器的对齐关系的,但实际使用中 却发现 似乎不是这样,请看如下代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="#AA009988">     <TextView         android:id="@+id/my_view"         android:layout_width="220dip"         android:layout_height="100dip"         android:text="sdfasdfsdfsdf\nsdfjlwjesd"         android:background="#889900AA"         *android:layout_gravity="center"* /> </LinearLayout> 我为 TextView 设置了 *layout_gravity="center"*- ,本来它应该在父容器中 垂直和水平 居中的,但事实上只是水平居中了,垂直方向并未居中。 我再进一步通过 *layout_gravity="**center_vertical**"* ,但仍然无法垂直居中,请问这是为什么呢?
  • 你可以在最外面的 LinearLayout 加上android:gravity="center". Vertical LinearLayout中, layout_gravity 设置成center无法垂直剧中,是因 为container的排版被限制为从上到下, 试想一下,如果按照你的逻辑,假设第一个child layout_gravity设置成bottom,   第二个childlayout_gravity设置成top,  那么第一个就会跑到第二个下面了。 所以, 当你设置整个linearlayout为垂直, layout_gravity中, 只有 left, right, center_ horizontal 管用的。 tj
Vincent Tsao

Applying Styles and Themes | Android Developers - 0 views

  •  
    using style/theme to make our layout views neat and maintainable
Vincent Tsao

android:layout_gravity android:gravity的区别 - China Android Dev | Google Groups - 0 views

  • 我看到一个最简洁的回复是(让我一直记得,哈哈): layout_gravity是本元素相对于父元素中的位置 gravity是本元素中内容相对自己的位置
Vincent Tsao

Onscreen Input Methods | Android Developers - 0 views

  • The android:inputType attribute has three pieces: The class is the overall interpretation of characters. The currently supported classes are text (plain text), number (decimal number), phone (phone number), and datetime (a date or time). The variation is a further refinement on the class. In the attribute you will normally specify the class and variant together, with the class as a prefix. For example, textEmailAddress is a text field where the user will enter something that is an e-mail address (foo@bar.com) so the key layout will have an '@' character in easy access, and numberSigned is a numeric field with a sign. If only the class is specified, then you get the default/generic variant. Additional flags can be specified that supply further refinement. These flags are specific to a class. For example, some flags for the text class are textCapSentences, textAutoCorrect, and textMultiline.
  •     <EditText android:id="@+id/edtInput"        android:layout_width="0dip"        android:layout_height="wrap_content"        android:layout_weight="1"        android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"        android:imeOptions="actionSend|flagNoEnterAction"        android:maxLines="4"        android:maxLength="2000"        android:hint="@string/compose_hint"/>
Vincent Tsao

用google adsense的小心了!!!! - China Android Dev | Google Groups - 0 views

  • google最后给的判决书: Hi, After further review from our abuse team we have confirmed that your account that was closed was modifying the ad behavior which is strictly prohibited as stated in the AdSense policies. These types of violations pose a significant risk to advertisers and for this reason we can no longer work with you through any partnering AdSense account or product offering. This will be the final communication about this issue. Please do not reply to this email as you will not receive a response. Thank you for your understanding. Google AdSense 我们自始至终都不知道原因。
  • 我Google了下 "modifying the ad behavior " 就是指你修改了 Google提供的 adsense js code 或者 sdk 唯一有可能的就是这里了 GoogleAdView adView = (GoogleAdView) activity.findViewById(R.id.ad<http://r.id.ad/> ); if (adView != null) { View vc = adView.getCurrentView(); if (vc instanceof WebView) { ((WebView) vc).destroy(); } View vn = adView.getNextView(); if (vn instanceof WebView) { ((WebView) vn).destroy(); } } 因为用了adsense之后 我们的程序老是crash 从stack trace看是因为Google adsense sdk 引起的. 资源没有释放. 然后去Adsense的那个mail list AFMA 问了 碰到2个都有同样问题的 然后有人给了个code 因为adsense sdk没有destroy ad view  所以要手动destroy下 我们就在每个有ads的activty的 onDestroy 加上这段 就好了 程序没有crash了 结果就被搞了 连负责我们android adsense sales都事先不知道 adsense team就直接把我们封了 还在beta 测试阶段的东西 还有bug  我们只是加了这个保证他资源正常释放不会影响到我们程序 结果就挂了 而且Google的态度巨NX无比 连个申述的途径都没有  只是给了个link类似事后调查
  • 我刚刚给我的sale发了一封信: Hi Sunil, It has been long that I haven't talked to you. I have a question, when I went to the application register page, I found the page layout was changed and some of my apps were gone. For example UK TV Guide, Australia TV Guide, etc. Also, the published status are all "false". I am confused because I am still seeing my ads are clicked in the daily report. Is there anything wrong? I am nervous because I just knew that an AdSense developer's account was disabled without any warning,  and the developers themselves don't know the reason. I don't want that happened on me so I really appreciate your comment. below is the letter in AFMA group. Looking forward to your reply. Thanks. Cheers, Luke 接下来我引用了superdroid的信。看看他怎么说吧。
  • ...1 more annotation...
  • 把这句抄下来了,大家以后小心了。 Ad Behavior AdSense code may not be altered, nor may the standard behavior, targeting or delivery of ads be manipulated in any way that is not explicitly permitted by Google. For instance, clicking Google ads may not result in a new browser window being launched. 我猜是不是可以找google总部投诉一下这个部门
Vincent Tsao

FrameLayout | Android Developers - 1 views

  • FrameLayout is designed to block out an area on the screen to display a single item. You can add multiple children to a FrameLayout, but all children are pegged to the top left of the screen. Children are drawn in a stack, with the most recently added child on top. The size of the frame layout is the size of its largest child (plus padding), visible or not (if the FrameLayout's parent permits). Views that are GONE are used for sizing only if setConsiderGoneChildrenWhenMeasuring() is set to true.
    • Vincent Tsao
       
      FrameLayout才是最有潜力的布局方式
Vincent Tsao

[Android] Defining custom attrs - Stack Overflow - 0 views

  • You can define attributes in the top <resources> element or inside of a <declare-styleable> element. If I'm going to use an attr in more than one place I put it in the root element. Note, all attributes share the same global namespace. That means that even if you create a new attribute inside of a <declare-styleable> element it can be used outside of it and you cannot create another attribute with the same name of a different type.
  • An <attr> element has two xml attributes name and format. name lets you call it something and this is how you end up referring to it in code, e.g., R.attr.my_attribute. The format attribute can have different values depending on the 'type' of attribute you want. reference - if it references another resource id (e.g, "@color/my_color", "@layout/my_layout") color boolean dimension float integer string fraction enum - normally implicitly defined flag - normally implicitly defined You can set the format to multiple types by using |, e.g., format="reference|color".
    • Vincent Tsao
       
      了然~
Vincent Tsao

Fragments | Android Developers - 1 views

  • If you add multiple changes to the transaction (such as another add() or remove()) and call addToBackStack(), then all changes applied before you call commit() are added to the back stack as a single transaction and the BACK key will reverse them all together.
    • Vincent Tsao
       
      what's the point to provide such  mechanism?
  • The most significant difference in lifecycle between an activity and a fragment is how one is stored in its respective back stack. An activity is placed into a back stack of activities that's managed by the system when it's stopped, by default (so that the user can navigate back to it with the BACK key, as discussed in Tasks and Back Stack). However, a fragment is placed into a back stack managed by the host activity only when you explicitly request that the instance be saved by calling addToBackStack() during a transaction that removes the fragment.
  • In some cases, you might need a fragment to share events with the activity. A good way to do that is to define a callback interface inside the fragment and require that the host activity implement it. When the activity receives a callback through the interface, it can share the information with other fragments in the layout as necessary.
  •  
    好特別、好酷的一個類
1 - 19 of 19
Showing 20 items per page