Is there an easy way to add a border to the top and bottom of an Android View?

In android 2.2 you could do the following. Create an xml drawable such as /res/drawable/textlines.xml and assign this as a TextView’s background property. <TextView android:text=”My text with lines above and below” android:background=”@drawable/textlines” /> /res/drawable/textlines.xml <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape android:shape=”rectangle”> <stroke android:width=”1dp” android:color=”#FF000000″ /> <solid android:color=”#FFDDDDDD” /> </shape> </item> <item android:top=”1dp” android:bottom=”1dp”> … Read more

Any way to declare a size/partial border to a box?

Not really. But it’s very easy to achieve the effect in a way that degrades gracefully and requires no superfluous markup: div { width: 350px; height: 100px; background: lightgray; position: relative; margin: 20px; } div:after { content: ”; width: 60px; height: 4px; background: gray; position: absolute; bottom: -4px; } <div></div>

Make a borderless form movable?

This article on CodeProject details a technique. Is basically boils down to: public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; [System.Runtime.InteropServices.DllImport(“user32.dll”)] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [System.Runtime.InteropServices.DllImport(“user32.dll”)] public static extern bool ReleaseCapture(); private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { … Read more

How can I show only corner borders?

Assuming <div id=”content”>CONTENT</div> and that CONTENT includes at least one HTML node. #content {position:relative} #content:before, #content:after, #content>:first-child:before, #content>:first-child:after { position:absolute; content:’ ‘; width:80px; height: 80px; border-color:red; /* or whatever colour */ border-style:solid; /* or whatever style */ } #content:before {top:0;left:0;border-width: 1px 0 0 1px} #content:after {top:0;right:0;border-width: 1px 1px 0 0} #content>:first-child:before {bottom:0;right:0;border-width: 0 1px 1px … Read more

How to remove the border highlight on an input text element

In your case, try: input.middle:focus { outline-width: 0; } Or in general, to affect all basic form elements: input:focus, select:focus, textarea:focus, button:focus { outline: none; } In the comments, Noah Whitmore suggested taking this even further to support elements that have the contenteditable attribute set to true (effectively making them a type of input element). … Read more

Border Gradient with Border Radius

2021: I recommend using the CSS mask method since the support is pretty good now You cannot use border-radius with gradient. Here is another idea where you can rely on multiple background and adjust the background-clip: .white-grad { background: linear-gradient(#ccc 0 0) padding-box, /*this is your grey background*/ linear-gradient(to right, #9c20aa, #fb3570) border-box; color: #313149; … Read more