Comments (9)
Would you list your xml layout you tried to convert?
from scaloid.
Sure
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 2 columns -->
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:id="@+id/textView1"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:text="Column 2" />
</TableRow>
<!-- edittext span 2 column -->
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<EditText
android:id="@+id/editText1"
android:layout_span="2"
android:text="Column 1 & 2" />
</TableRow>
<!-- just draw a red line -->
<View
android:layout_height="2dip"
android:background="#FF0000" />
<!-- 3 columns -->
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:id="@+id/textView2"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button2"
android:text="Column 2" />
<Button
android:id="@+id/button3"
android:text="Column 3" />
</TableRow>
<!-- display this button in 3rd column via layout_column(zero based) -->
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<Button
android:id="@+id/button4"
android:layout_column="2"
android:text="Column 3" />
</TableRow>
<!-- display this button in 2nd column via layout_column(zero based) -->
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<Button
android:id="@+id/button5"
android:layout_column="1"
android:text="Column 2" />
</TableRow>
</TableLayout>
This is the result:
import android.view.ViewGroup.LayoutParams
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
contentView = new STableLayout {
STableRow().<<.height(LayoutParams.WRAP_CONTENT).width(LayoutParams.WRAP_CONTENT).>>.padding(5 dip)
STableRow().<<.height(LayoutParams.WRAP_CONTENT).width(LayoutParams.WRAP_CONTENT).>>.padding(5 dip)
STableRow().<<.height(LayoutParams.WRAP_CONTENT).width(LayoutParams.WRAP_CONTENT).>>.padding(5 dip)
STableRow().<<.height(LayoutParams.WRAP_CONTENT).width(LayoutParams.WRAP_CONTENT).>>.padding(5 dip)
STableRow().<<.height(LayoutParams.WRAP_CONTENT).width(LayoutParams.WRAP_CONTENT).>>.padding(5 dip)
}.<<.fill.>>
}
from scaloid.
OK, definitely current version of Scaloid and its converter does not cover this issue. I will schedule it.
from scaloid.
So, table rows are not working at all?
Is there anything I can do to help?
from scaloid.
Scaloid always has a workaround: you can use the xml layout using plain-old Android API.
https://github.com/pocorall/scaloid#migration-tip
And based on some resources that I found, STableRow should be added to Scaloid.
http://stackoverflow.com/questions/1528988/create-tablelayout-programatically
http://stackoverflow.com/questions/9683006/android-stretching-rows-in-tablelayout-programmatically
If you willing to contribute to Scaloid, would you fix this issue?
from scaloid.
I spiked it out in my project to see if I could get it working.
I don't know if I am in the right path
TableLayout
class ETableLayout()(implicit context: android.content.Context, parentVGroup: TraitViewGroup[_] = null)
extends android.widget.TableLayout(context) with TraitTableLayout[ETableLayout] {
def basis = this
override val parentViewGroup = parentVGroup
implicit def defaultLayoutParams[V <: View](v: V): LayoutParams[V] = new LayoutParams(v)
override def +=(v: View) = {
var viw = v
viw = applyStyle(viw)
basis.addView(viw, defaultLayoutParams(viw))
basis
}
class LayoutParams[V <: View](v: V) extends TableLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f) with ViewGroupLayoutParams[LayoutParams[V], V] {
def basis = this
v.setLayoutParams(this)
def parent = ETableLayout.this
def >> : V = v
}
}
TableRow
class ETableRow()(implicit context: android.content.Context, parentVGroup: TraitViewGroup[_] = null)
extends android.widget.TableRow(context) with TraitTableRow[ETableRow] {
def basis = this
override val parentViewGroup = parentVGroup
implicit def defaultLayoutParams[V <: View](v: V): LayoutParams[V] = new LayoutParams(v)
class LayoutParams[V <: View](v: V) extends TableRow.LayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f) with ViewGroupLayoutParams[LayoutParams[V], V] {
def basis = this
v.setLayoutParams(this)
def parent = ETableRow.this
def >> : V = v
}
}
Am I missing something?
from scaloid.
Fixed to support STableLayout and STableRow
Layout converter will be fixed as well.
from scaloid.
Thanks!!
from scaloid.
@guersam did an awesome job on fixing this issue on layout converter. Now the example xml layout above is converted as:
onCreate {
contentView = new STableLayout {
this += new STableRow {
STextView("Column 1").textAppearance(android.R.attr.textAppearanceLarge)
SButton("Column 2")
}.<<.wrap.>>.padding(5 dip)
this += new STableRow {
SEditText().<<.span(2).>>.text("Column 1 & 2")
}.<<.wrap.>>.padding(5 dip)
this += new STableRow {
STextView("Column 1").textAppearance(android.R.attr.textAppearanceLarge)
SButton("Column 2")
SButton("Column 3")
}.<<.wrap.>>.padding(5 dip)
this += new STableRow {
SButton("Column 3").<<.column(2).>>
}.<<.wrap.>>.padding(5 dip)
this += new STableRow {
SButton("Column 2").<<.column(1).>>
}.<<.wrap.>>.padding(5 dip)
}.<<.fill.>>
}
Thanks @guersam!
from scaloid.
Related Issues (20)
- Fragments with Sviews HOT 1
- TypedResource(TR) Reload HOT 1
- SArrayAdapter cannot be added to after initialization HOT 2
- java.lang.IllegalArgumentException: Lint HOT 2
- Scaloid with Akka/Play Json or spray HOT 1
- Event gravity does not take parameters or application crashs HOT 9
- sbt android:package HOT 1
- Broken inheritance between S[...] objects (like SView or SLinearlayout) HOT 1
- broadcastReceiver function for String argument inconsistent with the function taking IntentFilter HOT 2
- STextView "here" not working with textSize defined HOT 1
- API 8, 9 support using Scala 2.10 and Scaloid 3.3 HOT 3
- Anko style HOT 1
- String resources getting mixed up when using Java + Scaloid? HOT 2
- problem code `def >> : V = v` HOT 4
- How to dynamically add view components to SLinearLayout or SVerticalLayout HOT 1
- How to initialize LocalServiceConnection from a fragment HOT 2
- no method getVisibleTitleHeight in android.webkit.WebView HOT 2
- How to use dependency injection in an activity. HOT 2
- How is this library implemented? HOT 4
- Performence issue of Scala on android (may not be related to scaloid) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scaloid.